Sql Server每日一练-Database Update - 用ASP编缉数据库记录
2010-07-17 19:33
483 查看
Database Update - 用ASP编缉数据库记录
<%' Defining some constants to make my life easier! (Same as Sample 1 & 2)
' Begin Constant Definition
' DB Configuration constants
' Fake const so we can use the MapPath to make it relative.
' After this, strictly used as if it were a Const.
Dim DB_CONNECTIONSTRING
DB_CONNECTIONSTRING = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & Server.Mappath
("./db_scratch.mdb") & ";"
' We don't use these, but we could if we neeeded to.
'Const DB_USERNAME = "username"
'Const DB_PASSWORD = "password"
'Now we override the above settings to use our SQL server.
'Delete the following line to use the sample Access DB.
DB_CONNECTIONSTRING = Application("SQLConnString") & "UID=" & Application("SQLUsername")
& ";PWD=" & Application("SQLPassword") & ";"
' ADODB Constants
' You can find these in the adovbs.inc file
' Do a search for it and it should turn up somewhere on the server
' If you can't find it you can download our copy from here:
' http://www.asp101.com/samples/download/adovbs.inc ' It may not be the most recent copy so use it at your own risk.
%>
<!-- #INCLUDE FILE="adovbs.inc" -->
<%
' End Constant Definition
%>
<%
Dim I ' Standard looping var
Dim iRecordToUpdate ' Id of deleted record
'We're going to keep this as simple as we can.
' 1. Create a Recordset object
' 2. Connect the Recordset to the table
' 3. Find the record to update
' 4. Update the record
' 5. Update the table
' 6. Close the Recordset
'Step 1:
Dim objRecordset
Set objRecordset = Server.CreateObject("ADODB.Recordset")
<%' Defining some constants to make my life easier! (Same as Sample 1 & 2)
' Begin Constant Definition
' DB Configuration constants
' Fake const so we can use the MapPath to make it relative.
' After this, strictly used as if it were a Const.
Dim DB_CONNECTIONSTRING
DB_CONNECTIONSTRING = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & Server.Mappath
("./db_scratch.mdb") & ";"
' We don't use these, but we could if we neeeded to.
'Const DB_USERNAME = "username"
'Const DB_PASSWORD = "password"
'Now we override the above settings to use our SQL server.
'Delete the following line to use the sample Access DB.
DB_CONNECTIONSTRING = Application("SQLConnString") & "UID=" & Application("SQLUsername")
& ";PWD=" & Application("SQLPassword") & ";"
' ADODB Constants
' You can find these in the adovbs.inc file
' Do a search for it and it should turn up somewhere on the server
' If you can't find it you can download our copy from here:
' http://www.asp101.com/samples/download/adovbs.inc ' It may not be the most recent copy so use it at your own risk.
%>
<!-- #INCLUDE FILE="adovbs.inc" -->
<%
' End Constant Definition
%>
<%
Dim I ' Standard looping var
Dim iRecordToUpdate ' Id of deleted record
'We're going to keep this as simple as we can.
' 1. Create a Recordset object
' 2. Connect the Recordset to the table
' 3. Find the record to update
' 4. Update the record
' 5. Update the table
' 6. Close the Recordset
'Step 1:
Dim objRecordset
Set objRecordset = Server.CreateObject("ADODB.Recordset")
相关文章推荐
- [Database] SQL Server 使用记录
- [Database] SqlServer: Sql Server中记录的用户信息
- Sql Server每日一练-可更新视图(Updateble views)
- dhl:获取sql server中一条update和insert语句影响的记录数 @@rowcount 和@@identity
- 如何获取sql server中一条update语句影响的记录数
- 如何在Sql Server中读取最近一段时间的记录,比如取最近3天的或最近3个月的记录。
- check_mssql_health监控sql server项目过程记录。
- SQL Server:几种查找和删除重复记录的方法
- SQL server和C#使用什么类型来记录金额
- SQL Server 索引基础知识(1)--- 记录数据的基本格式
- [SQL Server] TRIGGER 触发器获得insert, delete, update行的信息
- 怎么捕获和记录SQL Server中发生的死锁
- 一行转多行,一条记录转多条记录(sql server 2000)
- SQL SERVER 2008配置Database Mail –用SQL 数据库发邮件
- 每日随笔记录2016-05-13_1
- sql server中同时执行select和update语句死锁问题
- SQLiteDatabase中query、insert、update、delete方法参数说明
- SQL Server 开发之 数据记录拼接聚合
- 【原】[SQL Server] TRIGGER 触发器获得insert, delete, update行的信息
- SQL Server 2000查询表中无重复记录