Office中国论坛/Access中国论坛

标题: (已解决)这种数据的连接是怎么写来着,怎么老报错?说什么连接字符串属性无效 [打印本页]

作者: dreamice01    时间: 2008-2-3 15:22
标题: (已解决)这种数据的连接是怎么写来着,怎么老报错?说什么连接字符串属性无效
Public Function GetNewConnection() As ADODB.Connection
    Dim oCn As New ADODB.Connection
    Dim sCnStr As String
   
    sCnStr = "Provider='SQLOLEDB';Data Source='wangqiang';" & _
             "Integrated Security='SSPI';Database='accesstata';user_id='sa';password='120979120979'"
   
    oCn.Open sCnStr
   
    If oCn.State = adStateOpen Then
        Set GetNewConnection = oCn
    End If
End Function

Private Sub Command6_Click()
Dim cn As New ADODB.Connection
Dim rx As ADODB.Recordset
Dim user_online As Integer
Dim user_id As Integer
Dim user_name As String
user_online = 0
Set cn = GetNewConnection
   
Set rx = New ADODB.Recordset
'On Error GoTo Err_Command6_Click
    If IsNull(Text2) Or IsNull(Text4) Then
       MsgBox "没有输入用户名或密码,请重新输入", vbInformation, "系统提示"
       Exit Sub
    End If
    rx.Open ("select * from user_tbl where user_name=' " & Text2 & "' and user_password='" & Text4 & "'")

[ 本帖最后由 dreamice01 于 2008-2-27 09:39 编辑 ]




欢迎光临 Office中国论坛/Access中国论坛 (http://www.office-cn.net/) Powered by Discuz! X3.3