Dim num As Integer
Dim sql As String
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim com As ADODB.Command
Set cn = New ADODB.Connection
cn.CursorLocation = adUseClIEnt
num = Val(Text1.Text)
sql = "update articleinfo set state=''正常''where id=" & num & " and lendoutperson=''無''"
cn.ConnectionString = "Driver={SQL Server};Server=MICROSOFT01;UID=sa;PWD=sa;Database=articlemanaged"
cn.Open
Set rs = New ADODB.Recordset
rs.ActiveConnection = cn
Set com = New ADODB.Command
Set com.ActiveConnection = cn
rs.Open sql, cn, adOpenKeyset, adLockOptimistic
cn.Close
Set cn = Nothing
用recordset對數據庫進行的更新操作