Monday, March 17, 2014

MySQL VB.NET Tutorial 6 : Insert/Save data to database






Imports MySql.Data.MySqlClient
Public Class Form2
    Dim MysqlConn As MySqlConnection
    Dim COMMAND As MySqlCommand
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Form1.Show()
        Me.Hide()

    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        MysqlConn = New MySqlConnection
        MysqlConn.ConnectionString =
       "server=localhost;userid=root;password=root;database=database"
        Dim READER As MySqlDataReader


        Try
            MysqlConn.Open()
            Dim Query As String
            Query = "insert into database.edata (eid,name,surname,age) values ('" & TextBox_Eid.Text & "','" & TextBox_Name.Text & "','" & TextBox_SName.Text & "','" & TextBox_Age.Text & "')"
            COMMAND = New MySqlCommand(Query, MysqlConn)
            READER = COMMAND.ExecuteReader

            MessageBox.Show("Data Saved")
            MysqlConn.Close()

        Catch ex As MySqlException
            MessageBox.Show(ex.Message)
        Finally
            MysqlConn.Dispose()

        End Try
    End Sub
End Class


















------------------------------------------------------------------

How to: Insert New Records into a Database

Database Access with Visual VB.NET.NET

sql server - Insert Data into database in VB.NET

How to insert Data to Ms SQL server 2008 using VB.NET.net

.net - VB.NET insert data into SQL table

Using Visual VB.NET and SQL cannot insert data into table..‎

VB.NET import data from text file into sql databse line by line‎

store xml in SQL Server 2008 from VB.NET‎

Using SQL in VB.NET - Cannot insert data into SQL table

visual VB.NET - Could not Insert the data using V VB.NET in MYSQl

Add, save & retrieve data in SQL

insert data in sql 2005 from excel file through VB.NET asp.net‎

insert data into SQL table from pre filled boxes in VB.NET 4.0‎

insert into database unsing ado.net and VB.NET Visual Basic

Insert DateTime into SQL Server using VB.NET Visual Basic

Searches related to VB.NET insert data into sql Visual Basic

VB.NET insert data into sql table Visual Basic

VB.NET insert data into sql server Visual Basic

inserting data into sql table Visual Basic

insert query  VB.NET

sql insert statement from another table

No comments:

Post a Comment