我用edit让用户输入数据。然后我想把用户输入的数据添加到数据库内!我添加了edit1,edit2,edit3。数据库已经联接好了!我用了以下的语句:
Query1.Close;
Query1.SQL.Clear;
Query1.SQL.Add('Insert into shangwu (Id1 ,Id2 ,Id3)');
Query1.SQL.Add('Values(值,值,值)');
Query1.ExecSQL;
我该怎么把edit1,edit2,edit3里的内容添加到数据库内呢?
我的这个语句该怎么写啊?我该用什么连接符号呢??
Query1.Close;
Query1.SQL.Clear;
Query1.SQL.Add('Insert into shangwu (Id1 ,Id2 ,Id3)');
Query1.SQL.Add('Values(值,值,值)');
Query1.ExecSQL;
我该怎么把edit1,edit2,edit3里的内容添加到数据库内呢?
我的这个语句该怎么写啊?我该用什么连接符号呢??
Query1.SQL.Add('Values(@a,@b,@c)');
query1.Parameters.ParamByName('a') := edit1.text
...
query1.execsql;必要的时候做适当的类型转换。
我记得可以用连接符吧?
比如“+”,或是“&”
str :string;begin
str := 'Insert into shangwu (Id1 ,Id2 ,Id3) Values('''+trim(edit1.text)+''','''+trim(edit2.Text)+''','''+trim(edit3.Text)+''')';
Query1.Close;
Query1.SQL.Clear;
Query1.SQL.Add(str);
Query1.ExecSQL;
end;
lufancy的方法可行吗?我不知道是不是应该先定义a,b,c呢?
table1.fielebyName('字段').asstring:=edit1;
table1.post;
table1.fielebyName('字段').asstring:=edit1.text;
...
table1.post;