Insert data using SqlCommand : SqlCommand Insert « Database « VB.Net

Insert data using SqlCommand

Imports System
Imports System.Collections
Imports System.Data
Imports System.IO
Imports System.Xml.Serialization
Imports System.Windows.Forms
Imports System.Data.SqlClient

Public Class MainClass
    Shared Dim WithEvents con As SqlConnection

    Shared Sub Main()
        con = New SqlConnection("Server=(local)\SQLEXPRESS;Initial Catalog=MyDatabase;Integrated Security=SSPI") 

        Dim cmd As New SqlCommand()

        cmd.CommandText = "Insert into Employee (ID, FirstName, LastName) values(" & _
                          "1, 'Joe', 'Yin')"
        cmd.Connection = con

        End Try
    End Sub

End Class

Related examples in the same category

1.Insert command with parametersInsert command with parameters
2.Insert Data and Check resultInsert Data and Check result
3.Execute NonQuery To Insert Data and report how many rows affectedExecute NonQuery To Insert Data and report how many rows affected