This tutorial is all about on How to insert data in MySQL using VB.Net. Before you proceed, it is required that you create and understand a MySQL connection in your project. You need also to understand the basic MySQL queries because it is needed in this tutorial.
How To Create MySQL Connection In VB.Net
Step 1 - Create you own GUI with elements like text field, combo box, label, and button depending on your requirements.
Step 2 - Double click your button and insert the following codes below. Your button must be a Save button and it is use to insert data into MySQL database when user click it.
How To Create MySQL Connection In VB.Net
Step 1 - Create you own GUI with elements like text field, combo box, label, and button depending on your requirements.
Step 2 - Double click your button and insert the following codes below. Your button must be a Save button and it is use to insert data into MySQL database when user click it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Try | |
Dim Str As String = "INSERT INTO person (name,address,contact) VALUES('" & name.text & "','" & address.text & "','" & contact.text & "')" | |
conn.Open() | |
Dim mysc As New MySQLCommand(Str, conn) | |
mysc.executeNoneQuery() | |
MsgBox("Data Inserted!") | |
conn.Close() | |
Catch ex As Exception | |
MsgBox(ex.Message) | |
conn.Close() | |
End Try |
0 Comments