VB里面语句,怎么实现对SQL数据库里面数据的增删改查

2020-05-26 科技 146阅读
下面的例子就是对数据库进行添加删除修改的操作:
Private Sub Command1_Click()
For i = 0 To 5
Text1(i).Text = ""
Next i
Adodc1.RecordSource = "select * from " & s1 & " order by 编号"
Adodc1.Refresh
If Adodc1.Recordset.RecordCount > 0 Then
Adodc1.Recordset.MoveLast
Text1(0).Text = "G" + Format((Val(Right(Trim(Adodc1.Recordset.Fields("编号")), 4)) + 1), "0000")
Else
Text1(0).Text = "G0001"
End If
End Sub
Private Sub Command2_Click()
If Adodc1.Recordset.EOF = False Then
c = MsgBox("您确认要删除该记录吗?", vbOKCancel, "删除提示信息")
If c = vbOK Then
Adodc1.Recordset.Delete
Adodc1.RecordSource = "select * from 人员表"
Adodc1.Refresh
End If
Else
MsgBox "当前数据库中没有可删除的数据记录", vbOKOnly, "提示信息"
End If
End Sub
声明:你问我答网所有作品(图文、音视频)均由用户自行上传分享,仅供网友学习交流。若您的权利被侵害,请联系fangmu6661024@163.com