- 論壇徽章:
- 0
|
這是我的一段程序:定義了一個(gè)ODBC數(shù)據(jù)源,然后用游標(biāo)往數(shù)據(jù)庫(kù)插植,可是不管能取到多少條記錄,結(jié)果卻只插進(jìn)最后取到的那一條。插前面的都報(bào) SQLSTATE = S1004 [Microsoft][ODBC SQL Server Driver]無(wú)效的 SQL 數(shù)據(jù)類型這個(gè)錯(cuò)。你說(shuō)出錯(cuò)吧,它還能插進(jìn)最后一條。郁悶!是我的程序有問(wèn)題嗎?
大家?guī)臀铱纯戳耍?br />
sqlcd = create transaction
sqlcd.DBMS = "ODBC"
sqlcd.AutoCommit = False
Sqlcd.DBParm ="ConnectString='DSN=ybjk;UID=sa; PWD='"
connect using sqlcd;
if sqlcd.sqlcode <> 0 then
messagebox('錯(cuò)誤提示','與數(shù)據(jù)庫(kù)連接失敗!',stopsign!)
return
end if
DECLARE declare_dy CURSOR FOR
SELECT result.registerno,
result.accountno
FROM result
WHERE result.serial_no = :li_serial_1 using sqlcd ;
open declare_dy;
fetch declare_dy into :ls_register_no,:ls_account_no;
do while(sqlcd.sqlcode = 0)
INSERT INTO keepaccbill
( serial_no,
itemname,
itemspec)
VALUES (:li_serial_2,
:ls_register_no,
:ls_account_no) using sqlcd;
if sqlcd.sqlcode <> 0 then
messagebox('提示','插入數(shù)據(jù)有錯(cuò)誤'+ sqlcd.sqlerrtext)
rollback;
end if
fetch declare_dy into :ls_register_no,:ls_account_no;
loop
close declare_dy;
[ 本帖最后由 yejr 于 2006-6-8 08:54 編輯 ] |
|