说明:
1.kys 为数据表 包括(BH,MC,SL)三个字段
2.我要把 StringGrid1 的 东东加入 kys 表中
var
i,j:integer;
bhstr,mcstr:string;
SLINT:INTEGER;
begin
//form1.Query1.Close;
//form1.Query1.sql.Clear;
for i:= 1 to form1.StringGrid1.rowCount -1 do
begin
form1.Query1.Close;
form1.Query1.sql.Clear;
bhstr:=form1.StringGrid1.Cells[i,1];
mcstr:=form1.StringGrid1.Cells[i,2];
SLINT:=form1.StringGrid1.Cells[i,3];
form1.Query1.SQL.Add('insert into kys (BH,MC,SL) values (bhstr,mcstr,SLINT)'); //增加
form1.Query1.ExecSQL;
end;
//form1.Query1.ExecSQL;
end;
为什么 不对?谢谢了
1.kys 为数据表 包括(BH,MC,SL)三个字段
2.我要把 StringGrid1 的 东东加入 kys 表中
var
i,j:integer;
bhstr,mcstr:string;
SLINT:INTEGER;
begin
//form1.Query1.Close;
//form1.Query1.sql.Clear;
for i:= 1 to form1.StringGrid1.rowCount -1 do
begin
form1.Query1.Close;
form1.Query1.sql.Clear;
bhstr:=form1.StringGrid1.Cells[i,1];
mcstr:=form1.StringGrid1.Cells[i,2];
SLINT:=form1.StringGrid1.Cells[i,3];
form1.Query1.SQL.Add('insert into kys (BH,MC,SL) values (bhstr,mcstr,SLINT)'); //增加
form1.Query1.ExecSQL;
end;
//form1.Query1.ExecSQL;
end;
为什么 不对?谢谢了
解决方案 »
- TADOStoredProc的参数值出现乱码?
- 如何通过判断PageControl的标签页的焦点,来选择不同的语句?
- 如何取得点击窗口的句柄?
- 散分2 ,今晚放假!恭祝大家新出快乐!
- 如何获得当前dbgrid中选中的一条记录
- 使用oracle8.16的c/s数据库应用程度发布要哪些文件?
- 我该如何是好?
- 请问:有谁知道在delphi中最高效率插入10000条数据的方法?
- 菜问题:C++和Visual C++有什么不同?
- 如何在TREEVIEW中当点击一个父节点时,其下一层子树及本身的图标都变成另一幅?
- $$发送消息的问题$$ 一台Win2k ads在线升级到最新版之后,NetMessageBufferSend不能将消息发送给它(错误的返回值为2273),但是Net send可
- 如何得到当前sql server的连接数,在线等待,急急急急急急急急急急急
form1.Query1.Close;
form1.Query1.sql.Clear;
form1.Query1.SQL.Add('insert into kys (BH,MC,SL) values (:bhstr,:mcstr,:SLINT)'); //增加
for i:= 1 to form1.StringGrid1.rowCount -1 do
begin
form1.Query1.ParamByName('bhstr').Value := form1.StringGrid1.Cells[i,1];
form1.Query1.ParamByName('mcstr').Value := form1.StringGrid1.Cells[i,2];
form1.Query1.ParamByName('SLINT').Value := form1.StringGrid1.Cells[i,3];
form1.Query1.ExecSQL;
form1.Query1.Close;
end;
Query1.Append;???
你要把值传进去啊sblstr :string;
sblstr :='insert into kys(BH,MC,SL) values('''+bhstr+''','''+mcstr+''','+SLINT+')';
form1.Query1.sql.Clear;
form1.Query1.SQL.Add('insert into kys (BH,MC,SL) values (:bhstr,:mcstr,:SLINT)'); //增加
for i:= 1 to form1.StringGrid1.rowCount -1 do
begin
form1.Query1.ParamByName('bhstr').Value := form1.StringGrid1.Cells[i,1];
form1.Query1.ParamByName('mcstr').Value := form1.StringGrid1.Cells[i,2];
form1.Query1.ParamByName('SLINT').Value := form1.StringGrid1.Cells[i,3];
form1.Query1.ExecSQL;
form1.Query1.Close;
end;