Dear All,
I have this code :
Dim db1 As New ADODB.Connection
Dim cmd1 As New ADODB.Command
Dim param1, param2 As New ADODB.Parameter
db1.ConnectionString = "DSN=test database"
db1.Open
cmd1.ActiveConnection = db1
Set param2 = cmd1.CreateParameter("param1", adLongVarChar, adParamInput, 30)
cmd1.Parameters.Append param1
cmd1.Parameters("param1").Value = "test1"
Set param1 = cmd1.CreateParameter("param2", adLongVarChar, adParamInput, 30)
cmd1.Parameters.Append param2
cmd1.Parameters("param2").Value = "test2"
cmd1.CommandText = "insert into table1 (code,descr) values(?,?)"
cmd1.Execute
db1.Close
If I write the sql statement like this i it will take the param1 value in the field code and the param2 value in the field descr.
If i declare first the param2 and after the param1 it will do the opposite.
So i am wondering if i can put in the sql statement the parameter's names like :
cmd1.CommandText = "insert into table1 (code,descr) values(param1,param2)" etc.
Thanks a lot
Best Regards
I have this code :
Dim db1 As New ADODB.Connection
Dim cmd1 As New ADODB.Command
Dim param1, param2 As New ADODB.Parameter
db1.ConnectionString = "DSN=test database"
db1.Open
cmd1.ActiveConnection = db1
Set param2 = cmd1.CreateParameter("param1", adLongVarChar, adParamInput, 30)
cmd1.Parameters.Append param1
cmd1.Parameters("param1").Value = "test1"
Set param1 = cmd1.CreateParameter("param2", adLongVarChar, adParamInput, 30)
cmd1.Parameters.Append param2
cmd1.Parameters("param2").Value = "test2"
cmd1.CommandText = "insert into table1 (code,descr) values(?,?)"
cmd1.Execute
db1.Close
If I write the sql statement like this i it will take the param1 value in the field code and the param2 value in the field descr.
If i declare first the param2 and after the param1 it will do the opposite.
So i am wondering if i can put in the sql statement the parameter's names like :
cmd1.CommandText = "insert into table1 (code,descr) values(param1,param2)" etc.
Thanks a lot
Best Regards