Can anyone see why I get the error message "An unhandled exception of type System.InvalidCastException occurred in microsoft.visualbasic.dll
Additional information: Cast from type DBNull to type String is not valid." in the following code?
Additional information: Cast from type DBNull to type String is not valid." in the following code?
Code:
Private Sub Forward_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Forward.Click
Dim i As Integer
i = CInt(DataRecordNumber.Text) + 1
Dim MyConnection As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\housemi\My Documents\Visual Studio Projects\SnapShot.mdb")
MyConnection.Open()
Dim MyCommand As New OleDbCommand("SELECT * FROM Table1 WHERE ID =" & i, MyConnection)
Dim MyReader As OleDbDataReader = MyCommand.ExecuteReader()
While MyReader.Read