delphi高手請進(jìn),ADOcommand連SQLserver的問題adocommand1.CommandText:='update 卡片表 set 余額=''+yu_e+'' where 卡片編號='''+idtemp+''' ';adocommand1.Execute ;這條語句運(yùn)行時出錯,請問是什么原因呢?數(shù)據(jù)庫里面“余額”是float長度8。delphi里面yu_e是single。出錯提示為“將數(shù)據(jù)類型varchar轉(zhuǎn)換為float時出錯”。請問應(yīng)該怎樣解決呢?環(huán)境是delphi7,sqlserver.
熱心網(wǎng)友
你的第一條語句最后的結(jié)果是:update 卡片表 set 余額='+yu_e+' where 卡片編號='****' ,其中****是idtemp變量的實值。錯處在:余額='+yu_e+'上,余額是float,與一個字符串(+yu_e+)比較判斷,自然出錯。試試: adocommand1.CommandText:='update 卡片表 set 余額='+floattostr(yu_e)+' where 卡片編號='''+idtemp+''' ',如何?