You've used Invoke and Invoke required before :
http://www.codeproject.com/Questions/82446/A-small-error-thread.aspx[
^]
and we told you how to fix that problem. Why are you reverting back to old ways and not using it?
The only place that I can see where you would get that error is:
cmdoledb.CommandText = "SELECT NAME FROM table1 WHERE ID=" & CInt(Form1.txtid.Text)
If Form1.txtid.Text is not a valid integer value then you would get this error. It looks like in this case, that Form1.txtid.Text is blank.
You would be better using TryParse like this:
Dim intTemp as Integer
If Integer.TryParse(Form1.txtid.Text,intTemp)
cmdoledb.CommandText = "SELECT NAME FROM table1 WHERE ID=" & intTemp
Else
connecttodata.Close()
Return
End If
You also don't need to abort the thread. When the function ends, so will the thread. Telling it to abort as the last thing is unnecessary.
You also don't need to test boolean values against true or false (as in
While rdroledb.Read = True
If it already is a boolean value, then testing it again a boolean is just adding extra processing.