I have a form that is used to navigate through records in a table one at a time. The form generates the number of textboxes required automatically. Navigating through the records is easy enough, but when I click the update button it comes up with the error:
Object reference not set to an instance of an object.
Here is the code I have for when the Update button is clicked:
Dim con As New MySqlConnection Dim da As New MySqlDataAdapter Dim Query As New MySqlCommand For i As Integer = 0 To intNoColumns - 1 strUpdate &= l(i).Text & "='" & t(i).Text & "', " Next strUpdate = strUpdate.Substring(0, strUpdate.Length - 2) strUpdate &= " WHERE " & strPrimaryKey & "=" & l(intPrimaryKeyIndex).Text con.ConnectionString = frmLogin.strconn con.Open() Query.Connection = con Query.CommandText = strUpdate Query.ExecuteNonQuery() con.Close() Me.Close() frmStart.Show()
The error comes up in the for loop. How can I get around this error?
Thanks in advance for any help :)