[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.
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.
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?
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.
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?
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.
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
Re: Noob working with DB's
Whats the difference between them?
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.
Re: Noob working with DB's
Follow the last link in my signature for information on importing namespaces.
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.
Re: Noob working with DB's
You're welcome. Please mark your thread 'Resolved'.