aaronburro Sup, B 53068 Posts user info edit post |
I'm a total n00b to VB, though I don't think it'll be too hard to learn. What I'm wondering about, though, is how I will connect to an ODBC database for read access with it. I'm probably also going to need to connect to an Access db for read and write access, which I am also spectacularly n00bish on. I am creating/administering the Access db right now, but I'd like to write a VB front end so that I don't have to install Access on every machine in the office.
Basically, I'm hoping someone here can point me to some good resources, free or otherwise, that will help me learn what I need to learn or at least serve as a good reference or starting point for my questions. I'll be working w/ VB 6.0, btw.
Thx in advance 5/24/2006 5:01:59 PM |
LimpyNuts All American 16859 Posts user info edit post |
Use ActiveX Data Objects (ADODB). Really easy. Pretty much what you need is an:
ADODB.Connection - an object that manages your database connection ADODB.Recordset - your query results
Dim Conn as ADODB.Recordset Dim Rset as ADODB.Recordset
Set Conn = New ADODB.Recordset Conn.Open 'use appropriate conection string and such Set Rset = Conn.Execute("SQL QUERY HERE")
Rset.MoveFirst While Not Rset.EOF 'do something with your record Rset.MoveNext Wend
Conn.Close Set Conn = Nothing Set Rset = Nothing
You can leave the database connection open and run all the queries you want with it. Just remember to close it and set it to Nothing to free memory wen you're done with it. Depending on how you conect to the datbase, you may or may not be able to determine how many records are in the resulting recordset without looping through and counting.
[Edited on May 24, 2006 at 9:31 PM. Reason : ]5/24/2006 9:29:08 PM |