CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Jan 2008
    Posts
    10

    VB imports database question

    I'm trying to declare a database by doing

    Dim myDB As Database

    but it's saying database is not declared. Do i have to import something to do this???

  2. #2
    Join Date
    Jun 2004
    Location
    Kashmir, India
    Posts
    6,808

    Re: VB imports database question

    Are you trying to access some kind of database using VB 6? You will need to add a reference to Microsoft Data Access Object Library. However, I would suggest you use ADO. Search here you will get number of links to different samples that use ADO.

    Also while using ADO, you will have to add a reference to Microsoft ActiveX Data objects Library.

  3. #3
    Join Date
    Jan 2008
    Posts
    10

    Question Re: VB imports database question

    Yea, i'm trying to read/write infomation to a database using vb6.

    I'm reading and trying to follow through one of the tutorials i found (http://www.codeguru.com/vb/gen/vb_da...p/c15031/#more) but i'm still having problems. Below is part of the code i'm having problems with:


    Dim strSQL As String = "SELECT EmployeeID, FirstName, LastName, Location FROM tbl_Master"

    Dim da As New OleDbDataAdapter(strSQL, radarConnectionString)

    da.Fill(ds)




    Instead of writing the connection string code part out like in the example i just went to data->add new data source (think this does the same thing), and enter in the correct information (i think) and it told me the connection string was radarConnectionString. When i typed radarConnectionString as second pramater when declaring the OleDBdataAdapter variable it says radarConnectionString hasn't been declared.

    can someone tell me what the connection string variable is suppose to be and what the OleDbDataAdapter does with the sql string and the connection string variable.

    Thanks

  4. #4
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: VB imports database question

    Take a look at the link in my signature. It should help. Follow along with the included attachment
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

  5. #5
    Join Date
    Jun 2004
    Location
    Kashmir, India
    Posts
    6,808

    Re: VB imports database question

    You are confusing VB.NET code with VB 6. Which version of VB are you using? Is it VB.NET or VB 6. The code and link that you have posted are from VB.NET.
    Last edited by Shuja Ali; June 15th, 2008 at 04:54 AM.

  6. #6
    Join Date
    Jun 2004
    Location
    Kashmir, India
    Posts
    6,808

    Re: VB imports database question

    [ Moved to VB.NET Forum ]
    After reading the PM that I received from OP, it looks like that j8by7 is using VB 2005. I have moved the thread to VB.NET.

  7. #7
    Join Date
    Jun 2004
    Location
    Kashmir, India
    Posts
    6,808

    Re: VB imports database question

    You need to learn about ADO.NET basics prior to writing code. Please go through this article and you will be able to understand what exactly ADO.NET is for and how to use it.
    http://visualbasic.about.com/od/lear...y_for_data.htm

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

Featured