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?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
RBertoraCommented:
var
RecordNumber1 : Integer;

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

Rob ;-)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.