1.ADO
dim DBConnection as New ADODB.Connection
DBConnection.open "" '连接字符串
'定义对象
Set DBRecordset = New ADODB.Recordset
With DBRecordset
'初始化一些属性
.CursorLocation = adUseClient
.LockType = adLockOptimistic
.CursorType = adOpenStatic
Set .ActiveConnection = DBConnection
.Source = "select * from t_records where id=" & lRecordID
'打开数据集
.Open
If .EOF And .BOF Then
.AddNew
End If
.Fields!Title = LeftEx(Trim(txttitle.Text), 200)
.Fields!content = IIf(LeftEx(txtContent.Text, 30000) = "", " ", LeftEx(txtContent.Text, 30000))
.Fields!RecordType = lRecordType '更新数据
.Update
'关闭数据集
.Close
End With
2.sql
dim cn as new adodb.connection
cn.open ''
cn.execute "insert into tblname valuse('','','')"
cn.close
dim DBConnection as New ADODB.Connection
DBConnection.open "" '连接字符串
'定义对象
Set DBRecordset = New ADODB.Recordset
With DBRecordset
'初始化一些属性
.CursorLocation = adUseClient
.LockType = adLockOptimistic
.CursorType = adOpenStatic
Set .ActiveConnection = DBConnection
.Source = "select * from t_records where id=" & lRecordID
'打开数据集
.Open
If .EOF And .BOF Then
.AddNew
End If
.Fields!Title = LeftEx(Trim(txttitle.Text), 200)
.Fields!content = IIf(LeftEx(txtContent.Text, 30000) = "", " ", LeftEx(txtContent.Text, 30000))
.Fields!RecordType = lRecordType '更新数据
.Update
'关闭数据集
.Close
End With
2.sql
dim cn as new adodb.connection
cn.open ''
cn.execute "insert into tblname valuse('','','')"
cn.close
cnn.execute "insert into yourtable(field1 type1, filed2 type2) values ('xxxx', 'yyyy')"
cnn.execute "insert into yourtable(field1 type1, filed2 type2) values ('xxxx', 'yyyy')"
dim rst as new adodb.recordset
if cnn.state=adstateopen then ‘测试连接状态
cnn.close "" '连接字符串
end if
'定义对象
cnn.open
With rst
'初始化自定义的recordset的一些属性
.ActiveConnection = cnn
.CursorLocation = adUseClient
.CursorType = adOpenStatic
.LockType = adLockOptimistic
.Source = "select * from 表名"
'测试数据集状态并打开数据集
if .state=adstateopen then
.close
end if
.open
end with
set adodc1.recordset=rst
adodc1.addnew
!字段名=txtname 'txtname这里为输入框(textbox)
!字段名1=txtname1
!字段名2=txtname2
.........=.........
以上答案为标准答案,也是微软官方的在ADO加入记录标准示例,请你给我加分。谢谢!