Send a suggestion!

We're building a brand new version of the site, and we'd love to hear your ideas

Members

Technology Zones

IBM Learning Center

Articles

Hosted By

MaximumASP

Info

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

Last post 05-14-2008 5:40 AM by Frank R. Haugen. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 05-12-2008 11:22 AM

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

    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!

    -------------------------------------------

    -I code therfor I live-
    • Post Points: 10
  • Advertisement

    • Red Gate Software

    Advertisement

    Want to boost your .NET application performance?

    Some developers always seem to write efficient and lightening-fast code. What is their secret? It’s ANTS Profiler. “We improved the performance of the application up to 10 times” Dan Ports, Intrigma.

    Try it for yourself now.

  • 05-13-2008 4:22 PM In reply to

    • williamsg
    • Not Ranked
    • Joined on 10-11-2007
    • United Kingdom
    • Member
    • Points 235

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

    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

     

    I code, it's what I do
    • Post Points: 10
  • 05-14-2008 5:40 AM In reply to

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

    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

     

    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)

    -------------------------------------------

    -I code therfor I live-
    • Post Points: 5
Page 1 of 1 (3 items)