Results 1 to 2 of 2

Thread: ADOConnection not found

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2002
    Posts
    13

    Unhappy ADOConnection not found

    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
    Frenzied Member PilgrimPete's Avatar
    Join Date
    Feb 2002
    Posts
    1,313
    First off, your syntax looks a bit like C++/C#; you can't declare variables like that in VB.Net. Can you?

    Second, I don't know if there is an ADOConnection object in ADO.Net I've never seen it, but then again, I'm very new to .NET

    The example below might start you off:

    VB Code:
    1. Imports System.Data.OleDb
    2. Public Class DataAccess
    3.  
    4.  
    5.     Public Sub test()
    6.         Dim cnn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\test.mdb")
    7.         Dim cmd As New OleDbCommand("SELECT * FROM tblPlayers", cnn)
    8.         Dim da As New OleDbDataAdapter()
    9.         Dim ds As New DataSet()
    10.  
    11.         'open the connection
    12.         cnn.Open()
    13.         'set the dataadapter command
    14.         da.SelectCommand() = cmd
    15.         'fill the dataset
    16.         da.Fill(ds)
    17.         'write out the data to prove that we did something!
    18.         ds.WriteXml("c:\test.xml")
    19.         'close the connection
    20.         cnn.Close()
    21.         'clear up all those objects
    22.         ds = Nothing
    23.         da = Nothing
    24.         cmd = Nothing
    25.         cnn = Nothing
    26.     End Sub
    27.  
    28. End Class
    Or finish you off!

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