I am new to parameterized queries, and I am having a logic error (not syntax).
I need to update two related tables. I have declared two command objects on the form level (one for each table), and in form_load event I have appended parameters to both command object. This is because I think that it will take much less memory if I append only once parameters, and to reuse them (just to change their value property) later in the code. But it is not working. In save_event I have following code (more or less, I am typing it from head):
set rs=conn.execute("SELECT @IDENTITY From SomeTable",,adcmdtext)
cmd2.parameters(0).value=rs(0) ' related record (foreign key)
' and here I am looping through some grid rows
for cnt=1 to grid.rows-1
And the error is next:
It always inserts the same data - data that was first loaded in parameter. If I unload/load the form, it will insert correctly only 1 row per each table, and every next time I try to insert new data, it will insert the same data as the first time.
So, how to 'refresh' parameter values? Or I am having a bad approach here?