|
-
Jan 24th, 2006, 07:48 PM
#1
Thread Starter
New Member
[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
-
Jan 24th, 2006, 08:10 PM
#2
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.
-
Jan 24th, 2006, 08:18 PM
#3
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."
-
Jan 24th, 2006, 09:13 PM
#4
Re: talking to access
 Originally Posted by Mark Gambo
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!
-
Jan 24th, 2006, 09:15 PM
#5
Re: talking to access
 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."
-
Jan 24th, 2006, 09:20 PM
#6
Thread Starter
New Member
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
-
Jan 24th, 2006, 09:23 PM
#7
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
-
Jan 24th, 2006, 09:25 PM
#8
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:
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.
-
Jan 24th, 2006, 09:31 PM
#9
Thread Starter
New Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|