Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to get data from Access using ADO

Status
Not open for further replies.

vanGough

Programmer
Jun 19, 2002
4
US
Hi,

I am a new VB 6.0 programmer. How would I use ADO to get data from an Access database. I have a custname table a quote table and a quote item table. This is a one to many relationship. How would I get all the quotes for 1 customer? How would I get all the items for one quote?

Do I need to use stored procedures to extract the data and pass to a cursor?

Thanks for the help!

VanGough
 
To make a basic connection use the following code. You will notice that I have chosen to use a DSN connection but you can connect directly if you like.

Dim Conn As New ADODB.Connection
Dim cmd As New ADODB.Command
Dim rs As New ADODB.Recordset


Set Conn = New ADODB.Connection
Conn.ConnectionString = "DSN='dsn name'"
Conn.Open


With cmd
Set .ActiveConnection = Conn
.CommandText = "CustomerInfoQuery"
.CommandType = adCmdStoredProc
.Parameters.Append .CreateParameter("CustParam", adInteger, adParamInput, 6)
.Parameters("CustParam").Value = 'Parameter value' End With
rs.Open cmd, , adOpenDynamic, adLockOptimistic

If your query has no parameters then just leave out those two partameter lines. Add more parameters if you wish. Thanks and Good Luck!

zemp
 
Zemp,

Thanks for the update!

I am using the Jet Engine 4.0. Does jet 4.0 have different parms than jet 3.5?

I wanted to use an SQL extract from the code rather than a stored proc. SInce I want
multiple records would I need to get them all from the cursor for display purposes?

Also, what is a DSN connection?

Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top