不能从数据库里面取值,而是把变量赋给DBGRID里面!!如果能赋值 语句改怎么写
解决方案 »
- 散分,每个月总有那么郁闷的几天(二)
- 怎么用Delphi 7 读取SQL表格有多少行数据,把行数保存到一个变量里下面的能实现吗具体怎么做
- 终于升级到大阳,创建个delphi学习交流群,号码:24574069
- 哪位知道2006版怎么调出decision cube?
- exept on e:ereaderror do是什么意思呀
- 高分求firetoucher大哥,我知道你是高手,快救救小弟一把吧!这个问题不解决,下面进行不了了!
- 过来展现你们大侠的风采吧!
- ADO问题
- 求DELPHI 实现SQL server 动态链接语句
- 关于OA中的公文流转问题
- ×××系统空闲检测。我用了《超级猛料》里的方法,但××
- 聘高手开发!出银子了!急!!!简单的录音程序!
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Db, DBTables, Grids, DBGrids;type
TForm1 = class(TForm)
DBGrid1: TDBGrid;
DataSource1: TDataSource;
Table1: TTable;
ListBox1: TListBox;
Button1: TButton;
Button2: TButton;
Edit1: TEdit;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.DFM}procedure TForm1.Button1Click(Sender: TObject);
begin
listbox1.items.add(form1.dbgrid1.fields[0].asstring);
end;procedure TForm1.Button2Click(Sender: TObject);
begin
table1.edit;
form1.dbgrid1.fields[0].Value:=strtoint(edit1.Text);
end;end.百分这么好得:)
begin
listbox1.items.add(form1.dbgrid1.fields[0].asstring);
end;procedure TForm1.Button2Click(Sender: TObject);
begin
table1.edit;
form1.dbgrid1.v.fields[0].Value:=strtoint(edit1.Text);{这句用的DataSource.dataset就是指楼主的从数据库中直接取值}
end;end.
begin
listbox1.items.add(form1.dbgrid1.fields[0].asstring);
end;procedure TForm1.Button2Click(Sender: TObject);
begin
table1.edit;
form1.dbgrid1.DataSource.dataset.fields[0].Value:=strtoint(edit1.Text);{);{这句用的DataSource.dataset就是指楼主的从数据库中直接取值}
}
end;end.
上层的代码发错了,
Work with underlying tables whose internal data structure is unknown at runtime.If an application knows the data types of individual fields, then it can read or write individual field values through the Fields property. For example, the following statement assigns a field value to the Text property of an edit box:Edit1.Text := CustTable.Fields.Fields[6].AsString;Note: The preferred method for retrieving and assigning field values is to use persistent fields or the FieldByName method.The next statements assigns a value from an edit box to a field:CustTable.Edit;CustTable.Fields.Fields[6].AsString := Edit1.Text;CustTable.Post;Note: The AggFields property is a collection of all the dataset抯 aggregated fields. Thus, AggFields and Fields are mutually exclusive collections of the dataset抯 fields. These two properties contain all of the dataset抯 fields between them.
dbgrid1.Columns.Items[0].Title
有问题请发信息到我的E-mail:[email protected]