数据库的动态存储有关问题(BCB6.0+SQL Server 2000)
数据库的动态存储问题(BCB6.0+SQL Server 2000)
我想实现将采集来的数据实时存入到数据库中(BCB6+SQL Server 2000),但是有点不明白。
我建的表有两个字段,日期(datetime)和数据(float),日期我用了getdate()函数,没问题。而数据有点问题,模拟实时存入数据的过程,我用定时器模拟了这个过程,每1秒钟随机产生一个数,代码如下:
static float fad = 0;
fad = random(5);
不考虑会不会产生时差的问题,我想将fad存入数据库,见下面这句话
Query1->SQL->Add("insert into FYTable values(getdate(),fad)");
但是有错误。我想实现我所述的应该怎么改呢?
------解决方案--------------------
1.不允许使用列名
2.先AnsiString Strfad 取fad的字符串值;
Query1->SQL->Add("insert into FYTable values(getdate(),"+Strfad+")");
你先试试,我没试
我想实现将采集来的数据实时存入到数据库中(BCB6+SQL Server 2000),但是有点不明白。
我建的表有两个字段,日期(datetime)和数据(float),日期我用了getdate()函数,没问题。而数据有点问题,模拟实时存入数据的过程,我用定时器模拟了这个过程,每1秒钟随机产生一个数,代码如下:
static float fad = 0;
fad = random(5);
不考虑会不会产生时差的问题,我想将fad存入数据库,见下面这句话
Query1->SQL->Add("insert into FYTable values(getdate(),fad)");
但是有错误。我想实现我所述的应该怎么改呢?
------解决方案--------------------
1.不允许使用列名
2.先AnsiString Strfad 取fad的字符串值;
Query1->SQL->Add("insert into FYTable values(getdate(),"+Strfad+")");
你先试试,我没试