vb连接数据库

vb连接数据库,第1张

概述Private Sub cmd1_Click()     Dim cnn As ADODB.Connection   Dim my_recordset As ADODB.Recordset   Dim connect_string As String   Dim statestring As String   Set cnn = New ADODB.Connection   Set my_reco Private Sub cmd1_Click() Dim cnn As ADODB.Connection Dim my_recordset As ADODB.Recordset Dim connect_string As String Dim statestring As String Set cnn = New ADODB.Connection Set my_recordset = New ADODB.Recordset '连接Access数据库 connect_string = "DSN=medic_lib97;UID=;PSW=" cnn.Open connect_string Select Case cnn.State Case adStateClose statestring = "adStateClosed" Case adStateOpen statestring = "adStateOpen" End Select '显示连接的状态 MsgBox "连接成功!",statestring If Trim(Combo1.Text = "") Then MsgBox ("用户名不能为空,请重新输入!") txt2.Text = "" Combo1.SetFocus Else If Trim(txt2.Text = "") Then MsgBox ("密码不能为空,请重新输入!") txt2.Text = "" txt2.SetFocus Else my_recordset.Open "select * from user where ID='" & Combo1.Text & "'",cnn If my_recordset.EOF = True Then MsgBox ("用户名不存在!") Combo1.Text = "" txt2.Text = "" Combo1.SetFocus Else If (Trim(txt2.Text) = my_recordset.FIElds("passwd")) Then Me.HIDe Frm_main.Show 'MsgBox ("登陆成功!") Else MsgBox ("密码错误,登录失败!") txt2.Text = "" txt2.SetFocus End If End If End If End If End Sub 总结

以上是内存溢出为你收集整理的vb连接数据库全部内容,希望文章能够帮你解决vb连接数据库所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/1283523.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-09
下一篇 2022-06-09

发表评论

登录后才能评论

评论列表(0条)

保存