>I need to know how to state a variable in an Insert Into sql command.
>
>Set oConn = CreateObject("adodb.connection")
>myvariable = WorkSheets("Sheet1").Cells(1,1).Value
>oConn.Open("sde123")
>oConn.Execute("Insert Into mytable(field1, field2) Values(myvariable,"")
>oConn.Close
>
>Note this is code I am using in Excel to feed data into VFP. It works fine if I hard code the values but I need the flexibility of the variable.
Set oConn = CreateObject("adodb.connection")
myvariable = WorkSheets("Sheet1").Cells(1,1).Value
oConn.Open("sde123")
oConn.Execute("Insert Into mytable(field1, field2) Values("+myvariable+',""')
oConn.Close
or
Set oConn = CreateObject("adodb.connection")
myvariable = WorkSheets("Sheet1").Cells(1,1).Value
oConn.Open("sde123")
oConn.Execute("Insert Into mytable(field1, field2) Values(?myvariable,"")
oConn.Close
Wayne Myers, MCSD
Senior Consultant
Forte' Incorporated
"The only things you can take to heaven are those which you give away" Author Unknown