Blue Sky
March 3rd, 2001, 05:35 AM
I need to insert records into the 2 tables which are stored in SQL Server
The code :
....
....
sql1 = "Insert into TBL1 values" _
& "('" & idc & "','" & eng & "','" & chin & "','" _
& birth & "','" & add1 & "','" & add2 & "','" _
& add3 & "','" & idk & "','" & sex & "','" _
& phone & "','" & nat & "','" & photoPath & "','" _
& entry & "','" & leave & "','" & st & "','" _
& remark & "')"
sql2 = "Insert into TBL2 values" _
& "('" & id & "','" & gengn & "','" & gchinn & "','" _
& relation & "','" & gaddr & "','" & gphone & "','" _
& gphonew & "','" & mobile & "')"
'Enter the first record
conn.Execute sql1
conn.Execute sql2
The error message : "Method 'Execute ' of object 'Connection' failed"
Why?
I have checked the sql statements by inserting one variable by one. It works well, however,when I insert the variables up to, say 8, the program can't run and generated the above error statement
I don't know what happen. I think my sql statments are o.k.
I also tried to only executing sql2, i.e. conn.execute sql2 works well. It can insert values by sql2 to a referred table. But sql1 can't insert values to a referred table
The code :
....
....
sql1 = "Insert into TBL1 values" _
& "('" & idc & "','" & eng & "','" & chin & "','" _
& birth & "','" & add1 & "','" & add2 & "','" _
& add3 & "','" & idk & "','" & sex & "','" _
& phone & "','" & nat & "','" & photoPath & "','" _
& entry & "','" & leave & "','" & st & "','" _
& remark & "')"
sql2 = "Insert into TBL2 values" _
& "('" & id & "','" & gengn & "','" & gchinn & "','" _
& relation & "','" & gaddr & "','" & gphone & "','" _
& gphonew & "','" & mobile & "')"
'Enter the first record
conn.Execute sql1
conn.Execute sql2
The error message : "Method 'Execute ' of object 'Connection' failed"
Why?
I have checked the sql statements by inserting one variable by one. It works well, however,when I insert the variables up to, say 8, the program can't run and generated the above error statement
I don't know what happen. I think my sql statments are o.k.
I also tried to only executing sql2, i.e. conn.execute sql2 works well. It can insert values by sql2 to a referred table. But sql1 can't insert values to a referred table