Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27348

VS 2012 Need help constructing a mysql insert/update/remove statements

$
0
0
Right I wrote this out freehand from what i know and hope there is nothing wrong with it. It's wrote normally the way i write them in vb.net. Now i am getting into the parts where I need to start learning about WHERE part of the statement. And how to implement it in my code so that it works correctly. Right so, the below should import the textboxs yea? If not can someone please correct it and explain the correction if one is needed? Thanks. Code:
Code:

Try
                MysqlConn = New MySqlConnection()
                MysqlConn.ConnectionString = "server=#; user id=#; password=#; database=#"
                MysqlConn.Open()
                'Add sql commands
                Dim cmd As New MySqlCommand("Insert INTO `zeds` (`guid`, `NickName`, `name`, `username`) VALUES (@guid, @nickname, @username);", MysqlConn)
                cmd.Parameters.AddWithValue("@guid", ("ValueNo1TxtBox.Text"))
                cmd.Parameters.AddWithValue("@nickname", ("ValueNo2TxtBox.Text"))
                cmd.Parameters.AddWithValue("@username", ("ValueNo3TxtBox.Text"))
                cmd.ExecuteNonQuery()
                MysqlConn.Close()
               
            Catch myerror As MySqlException
               
            Finally
                MysqlConn.Dispose()
            End Try

Now my main question is, lets say i have a field called IPAddress in the database where zeds is. How would i go about rewriting the above code so that i can update only the IPAddress field in the database and not touch any of the other fields? For whoever explains this, if you can try to explain in a little detail as I am willing to learn this so i dont always need to post and ask over and over. I want to understand how to do this in my own code, and not one taken from a tutorial, as most of the help i have gotten on here was from other people who got me started in MySQL. Ident, Kebo, kaliman79912 to name a few. In a nut shell i want to know how i can change the above to only insert, update, remove from specific sections of a table.

Thanks guys

Viewing all articles
Browse latest Browse all 27348

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>