excel VBA有关循环执行sql语句的有关问题

fieldset{padding:10px;}

excel VBA有关循环执行sql语句的问题j = 6Do Until j = 1000000 str2 = "delete from dispose1121" str = "insert dispose1121 Exec pt_AppTempGetFiliationDispose @apptid=’" & Sheets("Sheet1").Cells(j, 16) & " ‘,@version=’" & Sheets("Sheet1").Cells(j, 17) & " ‘,@currentappdid=’" & Sheets("Sheet1").Cells(j, 18) & " ‘" str1 = "select count(*) as counts from dispose1121" rs.Open str2, strcon rs.Open str, strcon rs.Open str1, strcon Sheets("Sheet1").Cells(j, 7) = rs("counts")j = j + 1Loop如上一段VBA代码,j的初始值为6,在J=1000000之前循环执行str2,str,str1三条sql语句,当j=6时执行完3条语句,将counts值显示在第6行的第7列,然后开始循环,让J+1等于7,继续循环执行sql三条语句,就出错了。求救各位大侠,问题出在哪呢?——解决方案——————————————————–每次循环完成后,关闭RS试一下吧j = 6Do Until j = 1000000 str2 = "delete from dispose1121" str = "insert dispose1121 Exec pt_AppTempGetFiliationDispose @apptid=’" & Sheets("Sheet1").Cells(j, 16) & " ‘,@version=’" & Sheets("Sheet1").Cells(j, 17) & " ‘,@currentappdid=’" & Sheets("Sheet1").Cells(j, 18) & " ‘" str1 = "select count(*) as counts from dispose1121" rs.Open str2, strcon rs.Open str, strcon rs.Open str1, strcon Sheets("Sheet1").Cells(j, 7) = rs("counts")j = j + 1rs.closeLoop我们可以失望,但不能盲目。

excel VBA有关循环执行sql语句的有关问题

相关文章:

你感兴趣的文章:

标签云: