Imports System.Data.SqlClient Imports System.Data.SqlClient.SqlConnection Public Class Form1 Private cn As SqlConnection Dim constr As String Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load constr = "Integrated Security=SSPI;Initial Catalog=anand;Data Source=ANAND-PC\SQLEXPRESS;" End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim cmd As New SqlClient.SqlCommand Dim query As String query = "Insert Into anand1 (roll) values (" & TextBox1.Text & ");" cmd.CommandText = query cmd.CommandType = CommandType.Text cmd.Connection = cn cn.Open() cmd.ExecuteNonQuery() cn.Close() End Sub
cmd.CommandText = query cmd.CommandType = CommandType.Text cn = New SqlConnection(constr) cn.Open() cmd.Connection = cn
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)