|
-
Sep 10th, 2010, 02:11 PM
#1
Thread Starter
Fanatic Member
[RESOLVED] Noob working with DB's
I'm a newbie working on a project for my company to use VB 2008 Express.
Right now I'm trying to pull data from a DB
I've read this post http://www.vbforums.com/showthread.php?t=469872
it was very informative but I'm confused about something.
All I need to do is pull 1 row based on a number and display the data on the screen.
I'm good with the creating getting the specific number via a text box.
I'm looking to find some info on where and how to inlpement the SQL statement that results from the value of the text box.
"...Men will still say THIS was our finest hour"
If a tree falls in the woods and no one is there to see it, do all the other trees make fun of it?
-
Sep 10th, 2010, 10:49 PM
#2
Re: Noob working with DB's
That thread has everything you need. The second, third, fourth and fifth examples show you how to retrieve rows of data in various ways. The sixth example shows you how to add parameters to a command and set their values. You just put the two together. In this case, your SELECT statement will contain a WHERE clause containing a parameter.
-
Sep 11th, 2010, 08:04 AM
#3
Thread Starter
Fanatic Member
Re: Noob working with DB's
jmcilhinney,
I actually got it working I was going to update this thread this morning to say so. But here is another question:
I only have VB 2008 express which apparently doesn't support ODBC connections so what I did to get started was create an Access DB(2007) that pulls that data from the SQL Server and then connected to that DB via the described method. When we purchase the full version of VB 2008 will i have to to change anything more than the connection strings and the dataname methods?
"...Men will still say THIS was our finest hour"
If a tree falls in the woods and no one is there to see it, do all the other trees make fun of it?
-
Sep 11th, 2010, 08:50 AM
#4
Re: Noob working with DB's
There's no reason to be using ODBC anyway. If you want to connect to SQL Server then you should be using SqlClient, which VB Express does support.
-
Sep 11th, 2010, 05:10 PM
#5
Thread Starter
Fanatic Member
Re: Noob working with DB's
I guess that I'm a bit confused on how to do that. We've got a DB server that I'm trying to connect to via an IP Address. I'll give it a go on connecting to it.
I would use the same concept in the aformentioned thread and then go for a different connection string and change the setup to to a sqlclient?
"...Men will still say THIS was our finest hour"
If a tree falls in the woods and no one is there to see it, do all the other trees make fun of it?
-
Sep 13th, 2010, 07:21 AM
#6
Thread Starter
Fanatic Member
Re: Noob working with DB's
I've copied the code into my project for an SQL connection and am getting an error onr the first line.
SqlConnection is not a defined type.
"...Men will still say THIS was our finest hour"
If a tree falls in the woods and no one is there to see it, do all the other trees make fun of it?
-
Sep 13th, 2010, 07:36 AM
#7
Re: Noob working with DB's
You have to fully qualify it:
Code:
System.Data.SqlClient.SqlConnection
Or add IMPORTS to the top of your code:
Code:
Imports System.Data.SqlClient
VB6 Library
If I helped you then please help me and rate my post!
If you solved your problem, then please mark the post resolved
-
Sep 13th, 2010, 08:02 AM
#8
Thread Starter
Fanatic Member
Re: Noob working with DB's
Whats the difference between them?
"...Men will still say THIS was our finest hour"
If a tree falls in the woods and no one is there to see it, do all the other trees make fun of it?
-
Sep 13th, 2010, 08:53 AM
#9
Re: Noob working with DB's
Without using Imports you have to fully qualify any objects in the System.Data.SqlClient namespace whenever and where ever you reference them. Adding it maeans you don't.
VB6 Library
If I helped you then please help me and rate my post!
If you solved your problem, then please mark the post resolved
-
Sep 13th, 2010, 07:03 PM
#10
Re: Noob working with DB's
Follow the last link in my signature for information on importing namespaces.
-
Sep 15th, 2010, 10:59 AM
#11
Thread Starter
Fanatic Member
Re: Noob working with DB's
I've got it working now. Thank you so much for all of your helpful tips. I'm now moving on to the next problem which will be reading data in from a scale. Thank you again.
"...Men will still say THIS was our finest hour"
If a tree falls in the woods and no one is there to see it, do all the other trees make fun of it?
-
Sep 15th, 2010, 11:16 AM
#12
Re: Noob working with DB's
You're welcome. Please mark your thread 'Resolved'.
VB6 Library
If I helped you then please help me and rate my post!
If you solved your problem, then please mark the post resolved
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
|