I am trying to insert integer value in my SQLite table at Delphi.
In table emp usergroup_id is integer and label, description are string data type.
My code is as follows:
var
gid: Integer;
sdescription,ldescription: String;
begin
sdescription := RzEdit1.Text;
ldescription := RzMemo1.Text;
gid := Integer(RzComboBox1.Items.Objects[RzComboBox1.Items.IndexOf(gname)]);
try
SQLConnection1.Connected := true;
SQLMonitor1.Active := True;
sSql := 'INSERT INTO emp(usergroup_id, label, description) VALUES (gid,''' + sdescription + ''',''' + ldescription + ''' )';
SQLConnection1.ExecuteDirect(sSql);
except
on E: EDatabaseError do
ShowMessage('Exception raised with message' + E.Message);
end;
end;
It is giving me an error as Unknown column gid.
When I tried something like this with fixed integer value instead of variable it works:
sSql := 'INSERT INTO emp(usergroup_id, label, description) VALUES (1,''' + sdescription + ''',''' + ldescription + ''' )';
It inserts values successfully into table.
How to insert integer value of gid into database with above query. What would be the proper format?