Community discussion forum

VS 2008 VB.NET getting login, and account info from .mdb (X64 Vista)

  • 6 months ago

    as you can si from the specifications I have a hard time using alot of the recources on the web to get my results correct, since alot of whats written are written for earlier versions of VS but i have been lucky until now. I now have a problem I really can't handle since I'm not a pro (yet).

     I need to get information from a .mdb file while whould do this:

    1. check all in the "username" column for username macthing "textbox1"

    2. then if it finds a matching username it will se if the "password" field on the same row are the same as "textbox2"

     I have found some OK code snippets that i modified to do what i want but they are in another "dialect", for want of a better word, and does not work.

     If anyone could help I whould be greatfull.

     thanks in advance!

  • Advertisement

    Simply the fastest line-level profiler for .NET ever

    “The low overhead means it has minimal impact on the execution of my program”
    Mark Everest, Development Team Leader, Renault F1 Team Ltd.

    Try out the new ANTS Profiler 4 for yourself. Download your 14-day trial now

  • 6 months ago

    You probably want something like this:

    (Obviously subsituting EXAMPLE.mdb with the full path to your database [e.g. c:\example.mdb] AND also putting in the correct table name instead of SOMETABLE.) 

     

            Dim oConnection As New Data.OleDb.OleDbConnection
            Dim oCommand As New Data.OleDb.OleDbCommand
            Dim oReader As Data.OleDb.OleDbDataReader

            oConnection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0; data source=EXAMPLE.mdb"
            oCommand.Connection = oConnection
            oCommand.Connection.Open()
            oCommand.CommandText = "SELECT username, password FROM SOMETABLE"

            oReader = oCommand.ExecuteReader

            If oReader.HasRows Then
                While oReader.Read
                    If StrComp(oReader.Item("username"), TextBox1.Text, CompareMethod.Text) = 0 Then
                        If StrComp(oReader.Item("password"), TextBox2.Text, CompareMethod.Text) = 0 Then
                            MsgBox("Username and password match")
                        End If
                    End If
                End While
            Else
                MsgBox("No Data in table")
            End If

     

    You also might want to consider making the query:

    "SELECT username,password FROM SOMETABLE WHERE username =" & textbox1.text

     

  • 6 months ago

    [quote user="williamsg"]

    You probably want something like this:

    (Obviously subsituting EXAMPLE.mdb with the full path to your database [e.g. c:\example.mdb] AND also putting in the correct table name instead of SOMETABLE.) 

     

            Dim oConnection As New Data.OleDb.OleDbConnection
            Dim oCommand As New Data.OleDb.OleDbCommand
            Dim oReader As Data.OleDb.OleDbDataReader

            oConnection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0; data source=EXAMPLE.mdb"
            oCommand.Connection = oConnection
            oCommand.Connection.Open()
            oCommand.CommandText = "SELECT username, password FROM SOMETABLE"

            oReader = oCommand.ExecuteReader

            If oReader.HasRows Then
                While oReader.Read
                    If StrComp(oReader.Item("username"), TextBox1.Text, CompareMethod.Text) = 0 Then
                        If StrComp(oReader.Item("password"), TextBox2.Text, CompareMethod.Text) = 0 Then
                            MsgBox("Username and password match")
                        End If
                    End If
                End While
            Else
                MsgBox("No Data in table")
            End If

     

    You also might want to consider making the query:

    "SELECT username,password FROM SOMETABLE WHERE username =" & textbox1.text

     

    [/quote]

    Thank you very much!!!!

    It did not work until I set VS to compile and debug to x86 processors, (some problem with the Microsoft.Jet.OLEDB.4.0 provider, it seems tha MS haven't made a x64 versieon yet)

Post a reply

Enter your message below

Sign in or Join us (it's free).