sqlstring:='insert into login(user,password) values(:user,:password)';
with adoquery1 do
begin
connection:=Form1.ADOConnection1;
close;
sql.Clear;
sql.add(sqlstring);
Parameters.ParamByName('user').value:=trim(edit1.Text);
parameters.ParamByName('password').value:=trim(Edit2.text);
try
execsql;
为什么会报insert into语法错误!
with adoquery1 do
begin
connection:=Form1.ADOConnection1;
close;
sql.Clear;
sql.add(sqlstring);
Parameters.ParamByName('user').value:=trim(edit1.Text);
parameters.ParamByName('password').value:=trim(Edit2.text);
try
execsql;
为什么会报insert into语法错误!
parameters.ParamByName('password').asstring:=trim(Edit2.text);
sqlstring:='insert into login([user],[password]) values(:user,:password)';
with adoquery1 do
begin
connection:=Form1.ADOConnection1;
close;
sql.Clear;
sql.add(sqlstring);
Parameters.ParamByName('user').value:=trim(edit1.Text);
parameters.ParamByName('password').value:=trim(Edit2.text);
execsql;
'+user+','+
'+password+')';
一样可以执行,但是比较好调试,你可以把生成的代码直接到sql里面进行调试。
sSql := 'insert into login(user,password) values('+
'+''''+user+''''+','+
'+''''+password+''''+')';
with adoquery1 do
begin
connection:=Form1.ADOConnection1;
close;
sql.Clear;
sql.add(sqlstring);
Parameters[0].value:=trim(edit1.Text);
parameters[1].value:=trim(Edit2.text);
try
execsql;
....
....
直接生成sql查询字串比较容易调试
调试的时候只需在execsql前加showmessage就能检查sql语句组合是否正确了