This topic is locked

Insert Statement

5/9/2008 11:20:56 AM
ASPRunnerPro General questions
jadach authorDevClub member

Please help me.
What am I doing wrong? I want to add data to another table after the record is updated.
Here's my statement. When I try it I get an ASP Error.
Statement:
strSQLInsert = "INSERT INTO dbo.Narcotic_Audit (Narcotic, DateTime, QuantityDispensed, Unit, NewBalance, UserID, x_Lastname, x_Firstname) values (dict('Narcotic'), dict('DateTime'), dict('QuantityDispensed'), dict('Unit'), dict('NewBalance'), dict('UserID'), dict('x_Lastname'), dict('x_Firstname')"

dbConnection.Execute strSQLInsert
Error:
'dict' is not a recognized function name.
Thank you.

Sergey Kornilov admin 5/9/2008
strSQLInsert = "INSERT INTO dbo.Narcotic_Audit (Narcotic, DateTime, QuantityDispensed, Unit, NewBalance, UserID, x_Lastname, x_Firstname) values ( " & dict("Narcotic") & "," & dict("DateTime") & "," & dict("QuantityDispensed") ...


Do not forget to add single quotes around text field values.

jadach authorDevClub member 5/9/2008

Thank you. I get confused with what you said about single quotes for text feilds. All my values are as follows and it works
'" & dict("Feild_Name") & "'
I tried to take away the single quote from feilds that were numeric but received an error. Is it OK to use single quotes for all types of feilds?


strSQLInsert = "INSERT INTO dbo.Narcotic_Audit (Narcotic, DateTime, QuantityDispensed, Unit, NewBalance, UserID, x_Lastname, x_Firstname) values ( " & dict("Narcotic") & "," & dict("DateTime") & "," & dict("QuantityDispensed") ...


Do not forget to add single quotes around text field values.

Sergey Kornilov admin 5/11/2008

SQL standard requires to wrap text values by single quotes.
Right:

insert into table (field) values ('text')


Wrong:

insert into table (field) values (text)


I recommend you to check SQL tutorial at http://www.webcheatsheet.com/sql/interactive_sql_tutorial/

jadach authorDevClub member 5/11/2008

Thank you for all your help. I'll get it!

SQL standard requires to wrap text values by single quotes.

Right:

insert into table (field) values ('text')


Wrong:

insert into table (field) values (text)


I recommend you to check SQL tutorial at http://www.webcheatsheet.com/sql/interactive_sql_tutorial/