Results 1 to 9 of 9

Thread: [RESOLVED] talking to access

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2006
    Posts
    13

    Resolved [RESOLVED] talking to access

    Ok I am very new to vb.net and visual studio in general. I have an access database set up and would like to use that database with my vb.net windows application.

    I clicked on the data section of vs and now have a list of choices. Obviously oracle is not the one I want to use but there are several others. Which tool do I need to use to connect to the access db on my server and which tool do I need to use to run quieries?

    tia

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: talking to access

    You would use OleDb to interact with Access. Here is an example of using OleDb with the OLEDB Provider for Oracle. All you have to do is change the OLEDB Provider to use essentially the same code for Access. You do this via the ConnectionString of your OleDbConnection object. Visit www.connectionstrings.com for the appropriate value to use for Access.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3
    Giants World Champs!!!! Mark Gambo's Avatar
    Join Date
    Sep 2003
    Location
    Colorado
    Posts
    2,965

    Re: talking to access

    Same site as the one jmcilhinney posted but here is an example using Access: Data Access using MSAccess
    Regards,

    Mark

    Please remember to rate posts! Rate any post you find helpful. Use the link to the left - "Rate this Post". Please use [highlight='vb'] your code goes in here [/highlight] tags when posting code. When a question you asked has been resolved, please go to the top of the original post and click "Thread Tools" then select "Mark Thread Resolved."


  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: talking to access

    Quote Originally Posted by Mark Gambo
    Same site as the one jmcilhinney posted but here is an example using Access: Data Access using MSAccess
    Can you believe it? That's what I was looking for when I went to that site but I didn't see it. I think the clever disguise of putting "MS" in front of "Access" is what threw me. C'mon, anyone would have been fooled!
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5
    Giants World Champs!!!! Mark Gambo's Avatar
    Join Date
    Sep 2003
    Location
    Colorado
    Posts
    2,965

    Re: talking to access

    Quote Originally Posted by jmcilhinney
    Can you believe it? That's what I was looking for when I went to that site but I didn't see it. I think the clever disguise of putting "MS" in front of "Access" is what threw me. C'mon, anyone would have been fooled!

    and just think, I use to look up at you, oh well another icon bites the dust
    Regards,

    Mark

    Please remember to rate posts! Rate any post you find helpful. Use the link to the left - "Rate this Post". Please use [highlight='vb'] your code goes in here [/highlight] tags when posting code. When a question you asked has been resolved, please go to the top of the original post and click "Thread Tools" then select "Mark Thread Resolved."


  6. #6

    Thread Starter
    New Member
    Join Date
    Jan 2006
    Posts
    13

    Re: talking to access

    OK so I created the connection and am now attempting to load the command.

    dbQuery = New OleDbCommand("select * from drinks where drinks.drinkname like " + txtInput.Text + "%")

    dbQuery is my oledbcommand that I draged and dropped on my form.

    The underlined part is giving me a blue squiggle.

    Is it possable to change the command text depending on the event driven procedures chosen by the client?

    What is my issue here?

    tia

  7. #7
    PowerPoster
    Join Date
    Aug 2005
    Location
    College Station, TX
    Posts
    4,521

    Re: talking to access

    Well you should use "&" instead of "+" when concatenating strings, don't think that will solve your problem, but what error is it showing????? Error messages are important

  8. #8
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: talking to access

    You have to either import the System.Data.OleDb namespace at the top of the file, or else qualify the class name with the namespace:
    VB Code:
    1. dbQuery = New OleDb.OleDbCommand("select * from drinks where drinks.drinkname like [B][U]'[/U][/B]" [U]&[/U] txtInput.Text [U]&[/U] "%[B][U]'[/U][/B]")
    Note that only the OleDb is necessary as all WinForms applications already have a project wide import of the System.Data namespace.

    Two other things to note. I have replaced your addition operators with the proper string concatenation operators. "+" will work sometimes but not others so it is best avoided altogether so that you don't make mistakes. Also, strings in SQL code are enclosed in single quotes, which I have added.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  9. #9

    Thread Starter
    New Member
    Join Date
    Jan 2006
    Posts
    13

    Re: talking to access

    \Bar Tender\Form1.vb(798): Type 'OleDbCommand' is not defined.
    is the error message

    thanks for the note on the & and +. Originally I was using a "." (php) and it was giving me an eroor. There are just way to many different concat operators ;(

    and jmcilhinney that fixed the problem. thanks alot.

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