Dim dbCon As MySqlConnection Dim strQuery As String Dim SQLCmd As MySqlCommand Dim DR As MySqlDataReader dbCon = New MySqlConnection("server=*****; Database=*******; user id=******; password=******;") Try strQuery = "SELECT client.CompanyID, client.street, client.county, client.CompanyName, client.ClientForename, client.ClientSurname, client.PhoneNumber, client.town, client.postcode " & _ "FROM client " SQLCmd = New MySqlCommand(strQuery, dbCon) dbCon.Open() DR = SQLCmd.ExecuteReader While DR.Read TextBox1.Text = DR.Item("CompanyID") TextBox2.Text = DR.Item("CompanyName") TextBox3.Text = DR.Item("ClientForename") TextBox4.Text = DR.Item("ClientSurname") TextBox5.Text = DR.Item("Street") TextBox6.Text = DR.Item("Town") TextBox7.Text = DR.Item("county") TextBox8.Text = DR.Item("postcode") TextBox9.Text = DR.Item("PhoneNumber") End While DR.Close() dbCon.Close() Catch ex As Exception MsgBox("Failure to connect!" & ex.Message) End Try End Sub
This just shows my program connecting and displaying the first record. I am not experienced in VB so if my code looks rubbish please suggest ways to make it look better. I would extremely appreciate the help as it has been nagging me for the past few days.