|
-
Dec 29th, 1999, 12:31 PM
#1
Thread Starter
Hyperactive Member
Hi All,
Can anyone gimme a simple example of using a ADO with comments. I am trying to connect to access database and retrieve the values from a table.
I am totally new to ADO. Please help.
Regards,
Venkat.
-
Dec 29th, 1999, 02:22 PM
#2
Addicted Member
Hi there, the best you can do is take a look at th tuorial here on this site on using VB with databases, click on Databases, and you will find good tutorials.
happy Y2K
André
-
Dec 29th, 1999, 06:03 PM
#3
New Member
If you are going to connect to Access databases, its bette to continue with DAO instead of ADO, as it uses the JET database engine to connect to the native backend ie Access.
-
Dec 29th, 1999, 06:42 PM
#4
Thread Starter
Hyperactive Member
But, its the simpler way to learn ado instead of going for complex codes. pls..help me with some examples.
thanx.
regards,
venkat.
-
Dec 29th, 1999, 10:26 PM
#5
Guru
I have posted a relatively simple one here http://www.vb-world.net/ubb/Forum3/HTML/002333.html
BTW, ado still uses the MS Jet database engine, just via OLEDB, not DAO, and DAO will be fading away (if it hasn't already) so if you learn anything, learn ADO.
-
Dec 29th, 1999, 11:49 PM
#6
Hyperactive Member
Hi,there. Happy New Year!
Check Microsoft side, there is a lot of examples how to use ADO. http://msdn.microsoft.com/library/ps...k/mdae82eb.htm
Good luck!
Larisa
-
Dec 30th, 1999, 12:02 PM
#7
Here is a small example with comments. Requires Listbox (List1) and Command Button (Command1):
Code:
Private Sub Command1_Click()
Dim cn As New ADODB.Connection 'Connection object
Dim rs As New ADODB.Recordset 'Recordset object
Dim strDBPath As String
strDBPath = "C:\Program Files\Microsoft Visual Studio\VB98\Nwind.mdb"
'Set the native OLEDB provider for Jet (Access database)
cn.Provider = "Microsoft.Jet.OLEDB.3.51"
'Open connection for Northwind database, where the UserID is Admin and no password
cn.Open strDBPath, "admin", ""
'Open recordset for the Employees table
rs.Open "Select * from Employees", cn, adOpenStatic
'Populate the Listbox with last and first names
Do Until rs.EOF
List1.AddItem rs(1) & ", " & rs(2)
rs.MoveNext
Loop
rs.Close
Set rs = Nothing
cn.Close
Set cn = Nothing
End Sub
In this example I'm using Northwind database and a table called Employees.
------------------
Serge
Software Developer
[email protected]
ICQ#: 51055819
-
Dec 30th, 1999, 12:20 PM
#8
Thread Starter
Hyperactive Member
-
Dec 30th, 1999, 01:02 PM
#9
Member
Change
CN.Open "databse=database=d:\personal\payroll.mdb;Driver=Microsoft.Jet.OLEDB.3.51;"
to
CN.Open "Data Source=d:\personal\payroll.mdb;Provider=Microsoft.Jet.OLEDB.3.51"
This should work.
Ruchi
[This message has been edited by Ruchi (edited 12-31-1999).]
-
Dec 30th, 1999, 01:29 PM
#10
Thread Starter
Hyperactive Member
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
|