login screening converting from DAO to ADO

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • metalheadstorm
    New Member
    • Sep 2007
    • 84

    login screening converting from DAO to ADO

    Ok i have a working login screen on my project but its running the old DAO / data object style, but the rest of my project is is ADO / SQl ( i think :0 )

    This is what i have for the new ADO

    [CODE=vb]Public UserRS As New ADODB.Recordset
    Public UserCONN As New ADODB.Connectio n
    Public UserSQL As String ' global sql string
    Public HoldUser As String[/CODE]

    [CODE=vb] Function ConnectUser()
    Dim UserSQL As String
    Set UserCONN = New ADODB.Connectio n
    If UserCONN.State = 1 Then
    UserCONN.Close
    End If
    MSDatabaselogin = App.Path & ("\login.mdb ")
    UserSQL = "Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=" & MSDatabaselogin & ";Persist Security Info=False"
    UserCONN.Open (UserSQL), , , 0
    End Function

    Function OpenUserDB(User SQL As String)

    ConnectUser

    Set UserRS = Nothing
    If UserRS.State = 1 Then
    UserRS.Close
    End If

    UserRS.CursorLo cation = adUseClient
    UserRS.Open UserSQL, UserCONN, adOpenDynamic, adLockOptimisti c
    End Function
    [/CODE]

    And this is on the login command button

    [CODE=vb]
    UserSQL = "SELECT * FROM User"
    OpenUserDB (UserSQL)
    If (UserRS("Userid ") = Text1.Text) And (UserRS("passwo rd") = Text2.Text) Then
    Form1.Hide
    Main_menu.Show
    Main_menu.Capti on = "Welcome user..."
    Timer1.Enabled = True

    'Permissions
    Main_menu.mnu_A dmin.Enabled = False
    '-----------

    Exit Sub

    End If
    Exit Sub
    [/CODE]


    It comes up with an errors saying "Syntax in Error FROM clause"
    then highlights

    [CODE=vb]UserRS.Open UserSQL, UserCONN, adOpenDynamic, adLockOptimisti c[/CODE]

    Can anyone give any suggestions why this is happening ?
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    User is a reserved keyword and can't be used in sql statments. If you have a table named user ,rename it to somthing like apps_user or somthing more meaningful.

    Comment

    • metalheadstorm
      New Member
      • Sep 2007
      • 84

      #3
      ok ill have a look at that.

      Comment

      • metalheadstorm
        New Member
        • Sep 2007
        • 84

        #4
        thx that worked, btw is there a list anywhere that shows all the reserved words for vb ? if so then it would hopefully prevent this from happening again :)

        Comment

        • debasisdas
          Recognized Expert Expert
          • Dec 2006
          • 8119

          #5
          user is a keyword in database not in vb.

          Comment

          • metalheadstorm
            New Member
            • Sep 2007
            • 84

            #6
            Originally posted by debasisdas
            user is a keyword in database not in vb.
            ...well for acces then

            Comment

            Working...