Conn.ConnectionString = "Provider=SQLOLEDB.1;Password=ynhl95sms;Persist Security Info=True;User ID=sa;Initial Catalog=Report;Data Source=INFOHL95"
Conn.Openistr = "update temp_bill set qh=(select c3 from ynyd where substring(phone,1,7)=substring(c1,1,7)) where ftype='0201' or ftype='0202'"Conn.Execute istr这个语句没有错,在分析查询窗口执行没有问题只是执行时间过长,但是在VB中就会出错,提示 实时错误'-2147217871 (80040131)',超时已过期如何才能解决这个问题???
Conn.Openistr = "update temp_bill set qh=(select c3 from ynyd where substring(phone,1,7)=substring(c1,1,7)) where ftype='0201' or ftype='0202'"Conn.Execute istr这个语句没有错,在分析查询窗口执行没有问题只是执行时间过长,但是在VB中就会出错,提示 实时错误'-2147217871 (80040131)',超时已过期如何才能解决这个问题???
你可以设置超时的时间:
Conn.ConnectionTimeout = 60
比如设置为60秒二:
建议写成存储过程来完成,在存储过程里加上事务处理,如果不行,事务还可以回滚。我想60秒来执行你这个操作已经足够了,要不就是你的数据量太大或者数据库有问题
你得优化数据库,如加主键和索引
另外:你的sql语句能否先得到c3的值
select c3 from ynyd where substring(phone,1,7)=substring(c1,1,7)) 将c3返回一下,再update
update temp_bill set qh='" & c3 &"' where ftype='0201' or ftype='0202'