I have this sub which performs updates in successive function call. The reader object is closed only when the operation has been completed (after the while loop has ended), yet I get this error. Any suggestions?
sub reset_slno()
dim objCmd2 as new OleDBCommand()
dim objReader2 as OleDBDataReader
objCmd2.Connection = Conn
objCmd2.CommandText = "SELECT * FROM tbl_civil_works"
try
objCmd2.Connection.Open()
objReader2 = objCmd2.ExecuteReader
catch ex as exception
lblMessage.Text = ex.Message
end try
dim strSQL3 as String
dim record_counter as Integer = 1
while objReader2.Read()
strSQL3 = "UPDATE tbl_civil_works SET codeno = " & record_counter
ExecuteStatement(strSQL3)
record_counter = record_counter + 1
end while
objReader2.Close()
objCmd2.Connection.Close()
end sub
Error details:
Source Error:
Line 227: dim record_counter as Integer = 1
Line 228:
Line 229: while objReader2.Read()
Line 230: dim strSQL3 as String = "UPDATE tbl_civil_works SET codeno = " & record_counter
Line 231: ExecuteStatement(strSQL3)Source File: i:\inetpub\wwwroot\ecsite\civilworks1.aspx Line: 229