I'm attempting to retrieve an integer from a table using the below VB.NET snippet, but I'm getting an "Input string was not in a correct format" error. MyInt is not null, so that's not the problem. What am I doing wrong?
Dim MyInt As Integer
Dim conn = CreateObject("ADODB.Connection")
conn.Open("driver={SQL Server};server=(local);uid=MyUid;pwd=MyPwd;database=MyDatabase")
Dim rs = conn.Execute("SELECT MyInt FROM MyTable")
If Not rs.EOF Then
MyInt = CInt(rs("MyInt").ToString)
End If
rs.close()
conn.Close()
Our community of experts have been thoroughly vetted for their expertise and industry experience.