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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ADO

Status
Not open for further replies.

glenellis

IS-IT--Management
Jul 20, 2001
12
0
0
US
I have a "simple" program to write. Need to read an Access table, perform some calcs, then write new records out to a different Access table. Got a book on ADO and I'm not quite there yet.
I have attached the following test code. I've found that when I declare 2 tables, the 2nd one seems to be ignored. I proved this because the table TITLES does not exist in Extracts.MDB.

Questions;
1. To write output records only to a file, do I still need to Open it with a "Select" statement?
2. In sample code, how would I modify code so I can read/update two independent tables.

Thx in advance,
GlenEllis
 
Oops, here is the code.
==========
Private Sub Form_Load()
Set adoConnect = New Connection
Set adoConnect2 = New Connection

adoConnect.Open _
"Provider=Microsoft.JET.OLEDB.4.0;" & _
"Data Source=C:\temp\biblio.mdb;"

adoConnect2.Open _
"Provider=Microsoft.JET.OLEDB.4.0;" & _
"Data Source=C:\temp\extracts.mdb;"

Set adoRecordset = New Recordset
adoRecordset.Open "Select * from Publishers", _
adoConnect, adOpenStatic, adLockOptimistic

Set adoRecordset2 = New Recordset
adoRecordset2.Open "Select * from Titles", _
adoConnect, adOpenStatic, adLockOptimistic


If Not adoRecordset.EOF Then
' adoRecordset.MoveNext
adoRecordset.Fields(4) = "Sandown"
adoRecordset.Update
End If



If Not adoRecordset2.EOF Then
' adoRecordset.MoveNext
adoRecordset2.Fields(1) = 123
adoRecordset2.Update
End If

End Sub
 
The answer to your first question is no you do not have to use the "Select" statement. You can just use the open with the table name ie open "tblName". As far as your second question goes I am not clear as to what you are trying to do when you say "read/update two independant tables". Do you mean at the same time or read one and enter in the other? Anything is possible, the problem is I only have one lifetime.[thumbsup2]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top