我在SQL数据库中建了一张表,这张表要存储一些数据,表格的字段定为:data1,data2,data3,data4,data5......
现在我要用DELPHI来编一程序来输入数据,由于字段太多,要是一个一个写出来太麻烦,我想问一下能不能找一个搜索语句来搜索表格中的字段data1、data2、data3、data4...... 思路如下:
设定一整形变量 i,i 的值由程序来定
当i=1时,就往data1填数据,当i=2时,就往data2填数据,其它类推。可是会碰到几个问题
问题1:如何定位搜索指定的字段,例如怎样根据i=5直接找到字段data5 ?
问题2:如何赋值?赋值语句怎么写?这个问题就像DELPHI中的寻找组件的语句:tedit(findcomponent('edit'+inttostr(i))).text='abc'
我要解决的正是这种问题,只是我在这里不是要找组件,而是数据库中的表格字段罢了,请问怎么做?
在线等!!!
现在我要用DELPHI来编一程序来输入数据,由于字段太多,要是一个一个写出来太麻烦,我想问一下能不能找一个搜索语句来搜索表格中的字段data1、data2、data3、data4...... 思路如下:
设定一整形变量 i,i 的值由程序来定
当i=1时,就往data1填数据,当i=2时,就往data2填数据,其它类推。可是会碰到几个问题
问题1:如何定位搜索指定的字段,例如怎样根据i=5直接找到字段data5 ?
问题2:如何赋值?赋值语句怎么写?这个问题就像DELPHI中的寻找组件的语句:tedit(findcomponent('edit'+inttostr(i))).text='abc'
我要解决的正是这种问题,只是我在这里不是要找组件,而是数据库中的表格字段罢了,请问怎么做?
在线等!!!
goselect name from syscolumns where object_id('test') and colid=1
/*
name
------------
id
*/
select name from syscolumns where object_id('test') and colid=2
/*
name
------------
content
*/
select name from syscolumns where object_id('test') and colid=3
/*
name
------------
descript
*/
goselect name from syscolumns where id=object_id('test') and colid=1
/*
name
------------
id
*/
select name from syscolumns where id=object_id('test') and colid=2
/*
name
------------
content
*/
select name from syscolumns where id=object_id('test') and colid=3
/*
name
------------
descript
*/
tedit(findcomponent('edit'+inttostr(i))).text='abc'这样的DELPHI语句,谢谢
数据集.FieldByName( 'data'+IntToStr(i) ).Value := tedit(findcomponent('edit'+inttostr(i))).text;