I have a linked my vb.net project to an only SQL database which holds a list of predefined email addresses. My vb form contains a 'firstname','lastname' and 'email' textbox.
How do I program vb.net to locate the text in the 'email' textbox within the database and add the fistname and lastname textbox values to the appropriate column in the same row as the located email field? (filling the gaps)
My code so far:
' Initiate SQL Connection for db4free.net on port: 3306
MySqlConnection = New MySqlConnection
MySqlConnection.ConnectionString = "server=db4free.net; Port=3306; user id=username; password=password; database=databasename"
Try
MySqlConnection.Open()
Catch ex As Exception
MsgBox("The server could not be reached, check that you have internet connectivity and try again.", MsgBoxStyle.Critical, "Connection Error")
End Try
--- SQL DATABASE CONNECTION --- '
Dim Myadaptor As New MySqlDataAdapter
Dim sqlquery = "SELECT * FROM registration WHERE email='" & emailTextBox.Text & "';"
Dim command As New MySqlCommand
command.Connection = MySqlConnection
command.CommandText = sqlquery
Myadaptor.SelectCommand = command
Dim Mydata As MySqlDataReader
Mydata = command.ExecuteReader
' SQL Entry Validation
If Mydata.HasRows = 0 Then
MsgBox("Please enter a valid E-Mail address", MsgBoxStyle.Critical, "Invalid Details")
Else
--- THE ANSWER TO MY QUESTION (write firstname and lastname into row based on email) ---
Thank you in advance, (I only just started learning SQL).