向Access数据库中insert数据时错误
sbreceive1到sbreceive6是从一个Ansistring 中拆分出来的字符串
sbreceive1在Access对应的字段pdate为日期/时间型-短日期,形如“2012-05-02”
sbreceive2在Access对应的字段ptime为日期/时间型-长时间,形如“10:11:25”
程序运行时提示“标准表达式中数据类型不匹配”,但程序仍能运行,打开数据库,数据已经写进去了。
可是数据行却是隔行写入的,因为我发现自动编号字段是这样的“192 194 196 198 200”,怎么会这样啊?
AnsiString sql1 = "insert into record (peifang,xiliaodaihao,pdate,ptime,NW,TW,GW) values ('"+peifanghao+"','"+xiliaodaihao+"','"+sbreceive1+"','"+sbreceive2+"','"+sbreceive3+"','"+sbreceive4+"','"+sbreceive5+"');"; ADOQuery1->Close(); ADOQuery1->SQL->Clear(); ADOQuery1->SQL->Add(sql1); ADOQuery1->ExecSQL();
if(sqlExecute->DBConnection->ProviderName == "Access") tmpSQL = " rDate >= #"+DateEdit1->Text+"# and rDate <= #"+DateEdit2->Text+"# " ; else tmpSQL = " rDate >= '"+DateEdit1->Text+"' and rDate <= '"+DateEdit2->Text+"' " ;