Subject: Having problems retrieving an array to a table!
Posted By: penta Post Date: 9/25/2004 8:13:55 AM
Have array1 and have array2 printed on the immediate window.Array1 comes from tb1 and array2 comes from array1 and fieldE which is not
on tb1.Tb1 and tb2 have no fields in common to make a one-to-many relationship.I am having problems to insert array2 in tb2.Here comes the code:
      Sub InsertARecord1(str0 As Variant, str1 As Variant, _
    str2 As Variant, str3 As Variant, str4 As Variant)
Dim cmd1 As ADODB.Command

Set cmd1 = New Command

With cmd1
    .ActiveConnection = CurrentProject.Connection
    '.CommandText = "INSERT INTO Tb2(ID, " & _
        " Nome, Código, Evento, Dia1,Dia2,Dia3) VALUES (" & str0 & "," & str1 & "," & _
        str2 & "," & str3 & "," & str4 & ")"   
   
    .CommandText = "INSERT INTO Tb2 " & _
            "VALUES (" & str0 & "," & str1 & "," & _
       str2 & "," & str3 & "," & str4 & ")"
    .CommandType = adCmdText
    .Execute
End With

End Sub

I have filled strn with array2 and have tried naming the fields and
not naming the fields on the INSERT INTO command.Have not managed to fill Tb2 with strn VALUES.
Have error messages "missing parameters on query Tb2".
Any idea of what i am doing wrong or if this task is not possible are welcome.
Regards P.

Reply By: gokul_blr Reply Date: 9/27/2004 5:20:12 AM
Just be a little careful when you aren't too strict about the parameters that you expect. For example, although we have specified that some parameters are optional in this script, you should still check for them. If they aren't supplied, you should assign a default value rather than error out the script.

1. Check the no. of coloumns in the table as well as the no. of value paramenter specified in the query.
2. Check any mismatch of column Type in the sequence specified & to the table.
3. If you would like to skip any of the coloumn value the proper value should be passed as "NULL", (note : if the definition says NOT NULL value should be passed).



Gokulan Ethiraj
Reply By: penta Reply Date: 9/27/2004 7:23:56 AM
Thank u Gokulan for ur attention!
Have cheked ur itens 1,2,3 and now have error message "missing operator on query Tb2". Despite that i have created an intermediate tb3 linking Tb1 and Tb2 if that is something that may make this task easier.
Regards P.


Go to topic 19820

Return to index page 763
Return to index page 762
Return to index page 761
Return to index page 760
Return to index page 759
Return to index page 758
Return to index page 757
Return to index page 756
Return to index page 755
Return to index page 754