新手求教一个DBGrid的问题。20分 我已经取得了三个变量的值,DBGrid有三个字段,分别是‘编号’,‘类型’,‘时间’变量值分别是‘0001’,‘AAA','1979-10-30’如果现在我想在DBGrid中新添加一行并将这三个值分别赋予三个字段,请问我该如何操作??谢谢。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 用sql语句添加一条记录insert into tablename (‘编号’,‘类型’,‘时间’) values(‘0001’,‘AAA','1979-10-30’) 我的DBGrid没有和数据库连,只是单纯的想手工将这一行加入。是不是如果不和数据库连的话用别的类型更好?? with dbgrid do begin open;append;fieldByname('字段名称').value:=‘0001’;.....post;end;或者用SQL 的insert into 语句来实现 我的DBGrid没有和数据库连,只是单纯的想手工将这一行加入。是不是如果不和数据库连的话用别的类型更好?? 使用TClientDataSet创建一个临时数据集 DSetMain.Close; DSetMain.FieldDefs.Clear; DSetMain.FieldDefs.Add(‘编号’,ftString,255,false); DSetMain.FieldDefs.Add(‘类型’,ftString,255,false); DSetMain.FieldDefs.Add(‘时间’,ftString,255,false); DSetMain.CreateDataSet; DSetMain.Append; DSetMain.Fields[0].Vaule:= ‘0001'; DSetMain.Fields[0].Vaule:= ‘AAA'; DSetMain.Fields[0].Vaule:= '1979-10-30’; 使用TClientDataSet创建一个临时数据集 DSetMain.Close; DSetMain.FieldDefs.Clear; DSetMain.FieldDefs.Add(‘编号’,ftString,255,false); DSetMain.FieldDefs.Add(‘类型’,ftString,255,false); DSetMain.FieldDefs.Add(‘时间’,ftString,255,false); DSetMain.CreateDataSet; DSetMain.Append; DSetMain.Fields[0].Vaule:= ‘0001'; DSetMain.Fields[1].Vaule:= ‘AAA'; DSetMain.Fields[2].Vaule:= '1979-10-30’; 以TQuery为例在Query中的BeforeInSert里写上编号 := TQuery.FieldByName('编号').AsString;类型 := TQuery.FieldByName('类型').AsString; 时间 := TQuery.FieldByName('时间').AsString;然后在AfterInSert里写上TQuery['编号'] := 编号;TQuery['类型'] := 类型;TQuery['时间'] := 时间; 在票据打印的时候,有时打印正常,有时一打印打印在三张纸上? delphi用ODAC访问ORACLE的问题 想请教一下外挂的问题 combobox输入法 各位朋友,我知道你们只关心技术,其实我也一样 如何得到一個目錄下所有一種類型文件的文件名列表。謝謝! [DELPHI+ADO+SQL2000下的主從表問題],指點即送分 !!!腾讯QQ可能监测极度隐私 up给分 我以为...... 如何用DELPHI开发COM+组件 如何得到本程序执行文件的路径位置 我使用Delphi6的TDataBase控件连接Oracle数据库...还望高手指教。
insert into tablename (‘编号’,‘类型’,‘时间’) values(‘0001’,‘AAA','1979-10-30’)
是不是如果不和数据库连的话用别的类型更好??
begin
open;
append;
fieldByname('字段名称').value:=‘0001’;
.....
post;
end;或者用SQL 的insert into 语句来实现
是不是如果不和数据库连的话用别的类型更好??
DSetMain.Close;
DSetMain.FieldDefs.Clear;
DSetMain.FieldDefs.Add(‘编号’,ftString,255,false);
DSetMain.FieldDefs.Add(‘类型’,ftString,255,false);
DSetMain.FieldDefs.Add(‘时间’,ftString,255,false);
DSetMain.CreateDataSet;
DSetMain.Append;
DSetMain.Fields[0].Vaule:= ‘0001';
DSetMain.Fields[0].Vaule:= ‘AAA';
DSetMain.Fields[0].Vaule:= '1979-10-30’;
DSetMain.Close;
DSetMain.FieldDefs.Clear;
DSetMain.FieldDefs.Add(‘编号’,ftString,255,false);
DSetMain.FieldDefs.Add(‘类型’,ftString,255,false);
DSetMain.FieldDefs.Add(‘时间’,ftString,255,false);
DSetMain.CreateDataSet;
DSetMain.Append;
DSetMain.Fields[0].Vaule:= ‘0001';
DSetMain.Fields[1].Vaule:= ‘AAA';
DSetMain.Fields[2].Vaule:= '1979-10-30’;
在Query中的BeforeInSert里写上
编号 := TQuery.FieldByName('编号').AsString;
类型 := TQuery.FieldByName('类型').AsString;
时间 := TQuery.FieldByName('时间').AsString;然后在AfterInSert里写上
TQuery['编号'] := 编号;
TQuery['类型'] := 类型;
TQuery['时间'] := 时间;