whats wrong with this DB statement?

I have defined in a SQL 7 database (with two tables) the field name 'Record Number' which is stored in the Table 'Records' and 'NextRec' stored in the table 'NextRecordCount'. My SQL statment is trying to add the current value (an INT) of 'NextRec' in the Record Number field. Then after the post statement, I will inc (by 1)  the 'NextRec' so its ready for the next transistion. Here is a copy of my statement:

var
RecordNumber1 : Integer;

AddRecQuery.Sql.Add('Insert INTO Records(RecordNumber) values ('+ RecordNumber1 +')');

But I get an error that states:
"The name RecordNumber is not permitted in this context. Only constants, expressions, or variables are allowed here. Column names are not permitted."

Can anyone help me figure out where my error is? I alos have some string values that I need to add to the script too, but they cause an error saying the table expects an Integer, but gets a string value...(pointing to the recordnumber field).
routerboy309Asked:
Who is Participating?
 
RBertoraConnect With a Mentor Commented:
var
RecordNumber1 : Integer;

AddRecQuery.Sql.Add('Insert INTO Records(RecordNumber) values ('+ IntToStr(RecordNumber1) +')');

Rob ;-)
0
 
twolCommented:
I'm surprised the statement was accepted....shouldn't you have to convert the RecordNumber1 to a a string first....That's how I've always seen it....Then, when you get to the string values, you must submit them as single quoted strings. I usually use a function that performs this for me.

0
 
routerboy309Author Commented:
My mistake - Actually this is what I had before and it compiled. I added the extra stuff trying to get it to work.

AddRecQuery.Sql.Add('Insert INTO Records(RecordNumber) values (RecordNumber1)');

I tried this but it failed.

AddRecQuery.Sql.Add('Insert INTO Records(RecordNumber) values (StrToInt(RecordNumber1))');






0
 
routerboy309Author Commented:
Gees- I had the IntToStr backwards...Thanks.
0
 
RBertoraCommented:
It happens to the best of us
Thank you!
Rob ;-)
0
All Courses

From novice to tech pro — start learning today.