this is my code for the login form using ms access would someone please help me? Everytime I run the program, it usually says connection cannot be used. If I would debug the program it will highlight "rspassword.Open "Select * from table1"
I also used a module here

Public rs As New ADODB.Recordset
Public con As New ADODB.Connection
Public Sub OpenCon()
    Set con = New ADODB.Connection
    con.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source = " & App.Path & "\Database\enrollment.mdb"
End Sub



Dim con As New ADODB.Command
Dim rs As New ADODB.Recordset

Private Sub cmdcancel_Click()
Unload Me
End Sub

Private Sub cmdLogin_Click()
Set rspassword = New ADODB.Recordset
rspassword.Open "Select * from table1"
If rspassword.RecordCount > 0 Then
    Do Until rspassword.EOF
        If txtUsername.Text = rspassword!UserName And txtPassword.Text = rspassword!Password Then
            'frmmain.L1.Caption = Text1.Text
            Set rspassword = Nothing
            Unload Me
                frmmain.Show
                        ctr = 0
                Exit Do
                Else
          rspassword.MoveNext
            ctr = ctr + 1


        End If
        Loop
        If ctr > 0 Then
         Set rspassword = Nothing
                MsgBox "Invalid!", vbExclamation
                Text1.Text = ""
                Text2.Text = ""
                Text1.SetFocus
        ctr = 0
    End If
        End If
End Sub

Your open recordset parameter not completed.

Sub Open([Source], [ActiveConnection], [CursorType As CursorTypeEnum = adOpenUnspecified], [LockType As LockTypeEnum = adLockUnspecified], [Options As Long = -1])

It should looks like this :

rspassword.Open "Select * from table1", Con, adOpenDynamic, adLockBatchOptimistic

hie guys , this is my first time on this forum , am sorry i`m writting on this page , but i hope you cvan help with my visual studio 2008 , am trying to connect to my access database , but am having an error when i try to use my OleDbdataAdaptor , what could be the problem ?

1) This post belongs to johncornelius, please open you own thread.

2) You need to give us much more info, where does the error occur etc.

3) This is a vb6 forum, not for .net

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.