近期写了一个密码登陆窗口用ado 类连接串的使用不熟,测试时显示dbmssocn一般网络错误,不知何故 ,密码表名是mimabiao ;另外用vb调用access2000数据库文件显示不支持此格式mdb文件;Private Sub Command1_Click()
Dim strsql As String
Dim i As String
Dim m As String
'i = Text1.Text
'm = Combo1.Text
'Set gconn = New ADODB.Connection
'
'Dim strconn As String
'strconn = "provider=sqloledb.1;integrated Security=sspi;Persist Security Info=False;intial catalog=mimabiao;datasource=mimabiao;"
'gconn.Open strconn
'
'
' strsql = "select*from mimabiao where xm = '" & Trim(m) & "' and mm='" & Trim(i) & "'"
'Debug.Print strsql
' Dim r As New ADODB.Recordset
' r.Open strsql, gconn, adOpenStatic
' '错误次数
' Static ntrycount As Integer
' If r.EOF Then '登陆失败
' MsgBox "无此用户或密码", vbCritical, "错误"
' Text1.SetFocus
' Text1.SelStart = 0
' Text1.SelLength = Len(Text1)
' ntrycount = ntrycount = 1
'
' If ntrycount >= 3 Then
' MsgBox "再见!", vbCritical, "无权登陆"
' Unload Me
' gconn.Close
' End If
'Else
' Unload Me
' Form3.Show
' r.Close
'' exitsub
'End If
Dim strsql As String
Dim i As String
Dim m As String
'i = Text1.Text
'm = Combo1.Text
'Set gconn = New ADODB.Connection
'
'Dim strconn As String
'strconn = "provider=sqloledb.1;integrated Security=sspi;Persist Security Info=False;intial catalog=mimabiao;datasource=mimabiao;"
'gconn.Open strconn
'
'
' strsql = "select*from mimabiao where xm = '" & Trim(m) & "' and mm='" & Trim(i) & "'"
'Debug.Print strsql
' Dim r As New ADODB.Recordset
' r.Open strsql, gconn, adOpenStatic
' '错误次数
' Static ntrycount As Integer
' If r.EOF Then '登陆失败
' MsgBox "无此用户或密码", vbCritical, "错误"
' Text1.SetFocus
' Text1.SelStart = 0
' Text1.SelLength = Len(Text1)
' ntrycount = ntrycount = 1
'
' If ntrycount >= 3 Then
' MsgBox "再见!", vbCritical, "无权登陆"
' Unload Me
' gconn.Close
' End If
'Else
' Unload Me
' Form3.Show
' r.Close
'' exitsub
'End If
解决方案 »
- vb中如何将sql server中定义的作业编到程序中去
- "C" &1 & Chr$(13)和"C"&"1"&Chr(13)的区别
- 菜鸟问题:用ADO连接数据库,怎么删除和添加数据库中的记录?
- 帮我看看下面的代码
- vb加载webcatcher生成的chm帮助文件后,为什么程序老提示说那个文件不是windows的帮助文件或已破损
- 如何对庞大日志数据库纪录进行存储、删除、管理
- 请教
- Datagrid能否排序?
- 为何 Call DLL 慢很多, 如何让他变快呢
- 再发,“神哪!救救我吧” 关于Data Environment不刷新问题?(详情请进)
- Printer对象循环打印和打印定位的问题
- 100分问一个视频文件方面的问题
Option ExplicitPrivate Rs As New ADODB.Recordset
Private Conn As New ADODB.ConnectionPrivate Sub Form_Load()
Dim strConn As String
' 连接数据库的字符串
' 连接带密码的数据库,直接在连接符后面加上Jet OLEDB:DataBase Password='您的密码'
' 连接Access97数据库需要使用Jet.OLEDB.3.5,Access2K和以上数据库使用Jet.OLEDB.4.0
strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\test.mdb;Persist Security Info=False"
' 使用客户端数据游标
Conn.CursorLocation = adUseClient
' 打开Access的连接
Conn.Open strConn
' 如果RecordSet的状态不是关闭状态,则关闭Recordset
If Rs.State <> adStateClosed Then Rs.Close
' Recordser打开表People
Rs.Open "Select * from People", Conn, adOpenKeyset, adLockOptimistic
' 报告出 一共多少笔数据,测试是否存在数据
' MsgBox Rs.RecordCount
' 绑定进DataGrid
Set DataGrid1.DataSource = Rs
End Sub
谢谢!!!!!!!!' Recordser打开表People
Rs.Open "Select * from People", Conn, adOpenKeyset, adLockOptimistic
' 报告出 一共多少笔数据,测试是否存在数据
' MsgBox Rs.RecordCount
' 绑定进DataGrid
Set DataGrid1.DataSource = Rs
End Sub