I have an import routine that sets up data in an array and loops to HiArr
On each loop it assigns the last name and first name like so...
ILName := ArrayofUser[x].LName; //ImportLastName
IFName := ArrayofUser[x].FName; //ImportFirstName
Now I need to see if the ILName and IFName already exist in the table.
**FADC is another unit that holds the tables in the project
**I prefix all TUniQuerys with UQ, so I know what they are (just telling for readability)
FADC.UQUserTBLTest.SQL.Clear;
FADC.UQUserTBLTest.SQL.Text := 'SELECT * from UserTBLTest WHERE UserLName = ' + ILName +
' AND UserFName = ' + IFName;
FADC.UQUserTBLTest.Open;
First record being imported from the array is ILName of 'Barr**', ILFName of 'Mary'
Debugger Exception is Project Inventory.exe raised exception classs EMSError with message 'Invalid column name 'Mary', Invalid Column name 'Barr**'.'.
Funny thing is I can do this earlier....
FADC.UQUserTBLTest.SQL.Text := 'SELECT * from UserTBLTest WHERE UserTypeIDNo = ' + InttoStr(UserTypeIDNo) +
' AND DistrictIDNo = ' + InttoStr(DistrictIDNo);
And get no "invalid column name" errors. Same format.
Anyone have a clue what I'm doing wrong?
Thanks!
SQL.Text doesn't seem to be working in Delphi 10.3
Re: SQL.Text doesn't seem to be working in Delphi 10.3
Forgot to mention, I'm using MS SQL Server 2012
Re: SQL.Text doesn't seem to be working in Delphi 10.3
Ok, I finally got it.
Instead of what is in the original post, when working with the strings for the SQL.Text statement, you need to hyphenate as follows around the variables:
FADC.UQUserTBLTest.SQL.Text := 'SELECT * from UserTBLTest WHERE UserLName = ''' + ILName + ''' and UserFName = ''' + IFName +''''; // + '' + ILName + '' + ' AND UserFName = ' + '' + IFName + '';
Instead of what is in the original post, when working with the strings for the SQL.Text statement, you need to hyphenate as follows around the variables:
FADC.UQUserTBLTest.SQL.Text := 'SELECT * from UserTBLTest WHERE UserLName = ''' + ILName + ''' and UserFName = ''' + IFName +''''; // + '' + ILName + '' + ' AND UserFName = ' + '' + IFName + '';
Re: SQL.Text doesn't seem to be working in Delphi 10.3
I had some commented text in there....
Instead of what is in the original post, when working with the strings for the SQL.Text statement, you need to hyphenate as follows around the variables:
FADC.UQUserTBLTest.SQL.Text := 'SELECT * from UserTBLTest WHERE UserLName = ''' + ILName + ''' and UserFName = ''' + IFName +'''';
Instead of what is in the original post, when working with the strings for the SQL.Text statement, you need to hyphenate as follows around the variables:
FADC.UQUserTBLTest.SQL.Text := 'SELECT * from UserTBLTest WHERE UserLName = ''' + ILName + ''' and UserFName = ''' + IFName +'''';
Re: SQL.Text doesn't seem to be working in Delphi 10.3
Glad to see that the issue was resolved.
Feel free to contact us if you have any further questions about our products.
Feel free to contact us if you have any further questions about our products.