Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Insert
Message
 
To
All
General information
Forum:
Visual Basic
Category:
Database DAO/RDO/ODBC/ADO
Title:
Insert
Miscellaneous
Thread ID:
00899126
Message ID:
00899126
Views:
50
Hi All:
I am trying to insert a new record in my table. This table is in sql 2000. As I execute my codes, I get an error. Here is the description of the error I am getting.
"ODBC. The name Zack is not permitted in this context. Only constants,expression or variables allowed here. Column names are not permitted."

Please tell me what am I doing wrong!! Below is my code

Dim dbCommand As New ADODB.Command
Dim strSql As String
dbCommand.ActiveConnection = "DSN=TestConn;UID=sa;pwd=;"

lName = "Zack Ahmed"
lTitle = "DBA"
lAdd1 = "123 Main"
lCity = "Medina"
lState = "OH"

strSql = "Insert M2cexport Id_Name,Ind_Title,M2_Phadd1,M2Phcity,M2_Phstate) " & _
"Values (" & lName & "'" _
& lTitle & "'" _
& lAdd1 & "'" _
& lCity & "'" _
& lState & ")"

dbCommand.CommandText = strSql
dbCommand.Execute

I need all the help I can get
Thanks
MA
Next
Reply
Map
View

Click here to load this message in the networking platform