我要加一条记录,程序如下:
Private Sub Command1_Click()
Dim AdoCN As New ADODB.Connection '建立连接
Dim rs As New ADODB.Recordset '记录集
connstr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:/vbprograms/testdb.mdb;Persist Security Info=False"
AdoCN.Open connstr '打开
rs.CursorLocation = adUseClient
Dim x, y
If Text1.Text = "" Or Text2.Text = "" Or Text3.Text = "" Or Text4.Text = "" Then
x = MsgBox("您没有填全资料!", vbOKCancel, "警告")
y = 1
End If
If x = vbOK Then
Exit Sub
End If
If y <> 1 Then
sqlstr = "select * from student"
rs.Open sqlstr, AdoCN, adOpenKeyset, adLockOptimistic '游标类型
rs.AddNew
rs("name") = Text1.Text
rs("sex") = Text2.Text
rs("age") = Text3.Text
rs("height") = Text4.Text
rs.Update
rs.Close
End If
End Sub
用RS.OPEN加一条记录
猜你喜欢
转载自blog.csdn.net/xuexijiaoliu/article/details/5117342
今日推荐
周排行