Question connect (remotely) to a mysql

detect2173

New member
Joined
Mar 21, 2012
Messages
4
Programming Experience
1-3
Hello everyone. Today has been a good coding day. Although I am not a complete beginner, I am still learning a lot of new things everyday. So today I started a new learning project, and it is coming along really nicely. I was able to connect (remotely) to a mysql database. This database has one table and 1000 rows. Each row has an email address (which will serve as the primary key). The rows have 5 more cells each. So here is what I would like to learn today: (not looking for code, just looking for good direction)

I want the user to be able to input the email address in, say, a textbox control. I then want the click event for the button to search the database for that email. If it locates it, I want to then show the rest of the form fields in the windows form (I know how to do that part), and have the user input the rest of the data. Here's the tricky part (in my eyes)...

A) I am looking to do the search first (obviously)
B) The additional user inputted data needs to go in the appropriate row of the table.

To recap:

I have already made a successful connection to the database (Just in case it helps someone else, here is the code I used)

VB.NET:
Dim connection As MySqlConnection        
connection = New MySqlConnection()
connection.ConnectionString = "Server=domain.com; Uid=*****; Pwd=*****; Database=*****;"

        Try
            connection.Open()
            MessageBox.Show("Connection Opened Successfully")
            connection.Close()
        Catch mysql_error As MySqlException
            MessageBox.Show("Error Connecting to Database: " & mysql_error.Message)
        Finally
            connection.Dispose()
        End Try

This project serves no purpose other than for me to learn how to interact with, and manipulate a mysql database. (Just answering the popular question of "Why on earth would you want to do that?")

Again, I am not asking for someone to code this for me (defeats the purpose of learning and retaining), I am just asking for a little more than "look up the mysql class, it's all there"

Thank you! '

John
 
Last edited:
Create a MySqlCommand containing the appropriate query and call its ExecuteReader method to create a MySqlDataReader. It's HasRows property will indicate whether a match was found and you can then call Read to be able to access the data.
 
Ok, I got it...I was able to perform the query and test it. It worked flawlessly! Thank you. Now part two of three...

Is there a way to return what row it located the string on?

John
 

Latest posts

Back
Top