//假设你已经用AdoConnection连接到数据库 Procedure BtnInsertDateClick(……); var AdoQuery:TAdoQuery; begin AdoQuery:=TAdoQuery.Create(nil); AdoQuery.Connection:=AdoConnection; with AdoQuery do begin Close;
//假设你已经用AdoConnection连接到数据库 Procedure BtnInsertDateClick(……); var AdoQuery:TAdoQuery; begin AdoQuery:=TAdoQuery.Create(nil); AdoQuery.Connection:=AdoConnection; with AdoQuery do begin Close; SQL.Clear; SQL.Text:='Insert into TableName (FieldNameList) values (valueList)'; //在上面生成正确的SQL描叙。 //其中TableName 代表表名; //FieldNameList代表字段列表,用逗号格开 //valueList代表值的列表。 Prepared:=True; Try ExecSQL; Except MessageBox(0,'DATA NOT INSERT.','ERROR...',MB_ICONERROR); end; end;
如果不用dbedit的话好像只能这样了:
adoquery1.fieldbyname('字段1').asstring:=edit1.text
zhangl_cn(五台山的和尚也编程) 你能不能多给一些提示啊.写详细点,谢谢了.
adodateset.fieldByName('field1').assting:=edit1.text;
...
ado連access用jet引擎連呀。
var
AdoCon:TAdoConnection;
AdoQuery:TAdoquery;
begin
AdoCon:=TAdoConnection.Create(self);
AdoCon.ConnectionString:='Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\Documents and Settings\Administrator\My Documents\db1.mdb;Persist Security Info=False';
AdoQuery:=TAdoQuery.Create(self);
AdoQuery.Connection:=AdoCon;
With AdoQuery do
begin
close;
sql.Clear;
sql.Add('select * from t1');
prepared;
open;
insert;
fieldByName('ss').asstring:=edit1.text;
post;
end;
FreeAndNil(AdoCon);
FreeAndNil(AdoQuery);
end;
剩下对access文件操作,只需对adoquery进行各种操作就行了。
这里一段试列代码,你自己看看,能帮你解决问题
//假设你已经用AdoConnection连接到数据库
Procedure BtnInsertDateClick(……);
var
AdoQuery:TAdoQuery;
begin
AdoQuery:=TAdoQuery.Create(nil);
AdoQuery.Connection:=AdoConnection;
with AdoQuery do
begin
Close;
end;
这里一段试列代码,你自己看看,能帮你解决问题
//假设你已经用AdoConnection连接到数据库
Procedure BtnInsertDateClick(……);
var
AdoQuery:TAdoQuery;
begin
AdoQuery:=TAdoQuery.Create(nil);
AdoQuery.Connection:=AdoConnection;
with AdoQuery do
begin
Close;
SQL.Clear;
SQL.Text:='Insert into TableName (FieldNameList) values (valueList)';
//在上面生成正确的SQL描叙。
//其中TableName 代表表名;
//FieldNameList代表字段列表,用逗号格开
//valueList代表值的列表。
Prepared:=True;
Try
ExecSQL; Except
MessageBox(0,'DATA NOT INSERT.','ERROR...',MB_ICONERROR);
end;
end;