Results 1 to 2 of 2

Thread: ADOConnection Problems

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2002
    Posts
    13

    Unhappy ADOConnection Problems

    VB.NET
    -----------------------------------------------------
    I can't access to my access database via ado.net.
    When I type in :
    ADOConnection adoConnection = new ADOConnection()
    the keyword ADOConnection is underlined, and can't be found!!
    So, what shall I do?
    to import something??
    I've looked at so many examples of database accessing with ado.net in the internet, but nothing works!!
    Perhaps you could give me some examples, how i could access to an access db called login, with one table 'login' and there i want to update the field username where id = 3, for example!!!
    thx for your help!

  2. #2
    Hyperactive Member
    Join Date
    Dec 2001
    Location
    Dublin, Ireland
    Posts
    262
    well this is a vb.net forum so I'll be giving you the vb.net version of the code:-

    dim conn as new system.data.oledb.oledbconnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=fullpathtologin.mdb")
    dim cmd as new system.data.oledb.oledbcommand
    cmd.connection = conn
    cmd.commandtype = CommandType.Text
    cmd.commandtext = "update login set username='blah' where id=3"
    try
    conn.open
    cmd.executenonquery
    finally
    conn.close
    end try

    or to return data for display use an oledbdatareader:-

    dim conn as new system.data.oledb.oledbconnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=fullpathtologin.mdb")
    dim cmd as new system.data.oledb.oledbcommand
    dim dr as system.data.oledb.oledbdatareader
    cmd.connection = conn
    cmd.commandtype = CommandType.Text
    cmd.commandtext = "select password from login where username='blah'"
    try
    conn.open
    dr = cmd.executereader
    if dr.getvalue(0).tostring = PasswordTextBox.text then
    messagebox.show("Login Successful!")
    else
    messagebox.show("Invalid Password!")
    end if
    finally
    conn.close
    end try

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width