你在执行前面加一个错误扑捉: ON ERROR GOTO ERRINSSQL=“INSERT INTO 表名() VALUES()“ CON。EXECUTE SQLEXIT SUB ERRINS:
con.execute="insert 表名 values(值1,值2,...)" if err.number=0 then 成功 else end if
dim id as integer connection.execute "insert into table ()values",id if id = 0 then msgbox("未插入") else msgbox("插入id条记录") end if id 用来返回sql语句的执行记录
err.number=0 connection.execute "insert into table ()values",id if id>0 and err.number=0 then msgbox "成功" else 1 end if
xing0091() 的处理方法是正确的,这是一个ADO的方法。>>dim id as integer >>connection.execute "insert into table ()values",id >>if id = 0 then >> msgbox("未插入") >>else >> msgbox("插入id条记录") >>end if >>id 用来返回sql语句的执行记录 有时是逻辑上的错误,用错误捕足的方法是不行的
ON ERROR GOTO ERRINSSQL=“INSERT INTO 表名() VALUES()“
CON。EXECUTE SQLEXIT SUB
ERRINS:
if err.number=0 then
成功
else
end if
connection.execute "insert into table ()values",id
if id = 0 then
msgbox("未插入")
else
msgbox("插入id条记录")
end if
id 用来返回sql语句的执行记录
connection.execute "insert into table ()values",id
if id>0 and err.number=0 then
msgbox "成功"
else
1
end if
>>connection.execute "insert into table ()values",id
>>if id = 0 then
>> msgbox("未插入")
>>else
>> msgbox("插入id条记录")
>>end if
>>id 用来返回sql语句的执行记录
有时是逻辑上的错误,用错误捕足的方法是不行的
错误捕捉代码请参考connection的errors集合。以上回复均不完全。