Click to See Complete Forum and Search --> : VB imports database question


j8by7
June 14th, 2008, 10:55 AM
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???

Shuja Ali
June 14th, 2008, 01:08 PM
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.

j8by7
June 14th, 2008, 09:41 PM
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_database/adonet/article.php/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

dglienna
June 14th, 2008, 11:11 PM
Take a look at the link in my signature. It should help. Follow along with the included attachment

Shuja Ali
June 15th, 2008, 04:49 AM
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.

Shuja Ali
June 15th, 2008, 11:19 AM
[ 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.

Shuja Ali
June 15th, 2008, 11:23 AM
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/learnvbnetandadonet/Learn_how_to_use_ADONET_Microsofts_NET_technology_for_data.htm