Re: ADO conditional insert, update, or delete
- From: "Paul Randall" <paulr901@xxxxxxxxxxxx>
- Date: Tue, 18 Dec 2007 18:28:58 -0700
"billy" <wcasse@xxxxxxxxx> wrote in message
news:f30ff1b6-5275-4dd8-9bfe-695a5e8c05e4@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I have not been able to find a good example of this and was hoping
that someone might have one or a helpful URL. Specifically, when to
use CreateObject("ADODB.Recordset") and what should my sql querys
be.
I have a multi-dimensional array and an Access database. What I am
trying to do is to compare the array to the database:
If MyArray(0,0) does not exist in the database, then insert
MyArray(0,0) and MyArray(1,0) into table1.
If MyArray(0,1) is equal to table1-recordset1-field1 and
MyArray(1,1)
is equal to table1-recordset1-field2 then do nothing.
If MyArray(0,2) does exist and MyArray(1,2) is NOT equal to
recordset2-
field2 then update recordset2.
Next, I think I need a separate loop to go through the database and
delete recordsets that do not exist in the array.
I only know enough about ADO and SQL to be dangerous. Hopefully
someone with more knowledge will jump in here.
It sounds to me like one SQL statement could do most of the work. A
left join of your array and table1 might contain the result you want.
Perhaps you could save your array to a file in CSV format. I think
SQL can left join the data from the CSV file with the data from the
database's table 1, and put the result into a new table 1. I would
suggest going through the ADO and SQL tutorials at
http://www.w3schools.com.
-Paul Randall
.
- References:
- ADO conditional insert, update, or delete
- From: billy
- ADO conditional insert, update, or delete
- Prev by Date: Re: Question about VB scripting
- Next by Date: Two Questions
- Previous by thread: ADO conditional insert, update, or delete
- Next by thread: Re: ADO conditional insert, update, or delete
- Index(es):
Relevant Pages
|
Loading