-
Visual Basic and Access
I'm working on a school project in VB, and quite frankly, the teacher sucks...not teaching us what we need. My project involves using an Access Database and executing SQL statements on it and showing/inputing data etc. My problem isn't SQL, it's how to connect to the damn database....I'v googled it to death, and I'v not found any useful source or walk through, aswell as the books I have are useless. Soo....I turn to AO; any one here willing to show me how to create a connection to a database and how to open/close it and hopefully how to execute SQL on it if they have time.
Bleh....I need to go tell me teacher off for being useless!
- Noia
-
-
hmmm...it worked...and then it was as if it was /.'d DNS failure. Still, didn't contain alof of Syntax as far as I could see, but I didn't get to read it all either.
-
They tell you further into that section how to make a connection to a jet database via ado, and then even further down how to work with it. You need to do the research to understand how it all works.
-
Hmm, yea...Just these books and tuts I'v read are all messed up....I'm really confused now :s
-
Are we talking VB6 or VB.Net?
-
-
VB6, sorry, should have mentioned.
-
This will get you a connection to your database.
dim cnn as adodb.connection
With cnn
.Provider = "Microsoft.Jet.OLEDB.4.0"
.Properties("Jet OLEDB:System Database") = c:\mymdw.mdw
.Properties("Jet OLEDB:Database Locking Mode") = adLockOptimistic 'row-level locking
.Properties("User ID") = "User"
.Properties("Password") = "Password"
.Open c:\mydb.mdb
.Properties("Jet OLEDB:Lock Retry") = 5
End With
'With the connection you can then create recordsets.
Dim rst as recordset
Set rst = New Recordset
rst.Open "Select * from MyTable", cnn, adOpenForwardOnly, adLockReadOnly
' Then loop through the recordset
-
I like VB, and I'm not to good with Databases, but good enough.
www.vbexplorer.com (forums and tuts)
www.planetsourcecode.com (ultimate for code examples)