I want to insert values from vb textbox in sql table named [home] and my code is
Private Sub Button1_Click_1 (ByVal sender As System.Object, ByVal e As System.EventArg s) Handles Button1.Click
Dim result As Integer
Dim conn As New OleDb.OleDbConn ection("provide r=SQLOLEDB;User ID=sa;password= xxxxxx;Initial Catalog=first;d ata source=NAVEEN;" )
conn.Open()
Dim insert1 As New OleDb.OleDbComm and
insert1 = New OleDb.OleDbComm and("insert into home values('" + TextBox1.Text + "','" + TextBox2.Text + "'),conn")
insert1.Command Type = CommandType.Tex t
result = insert1.Execute NonQuery()
conn.Close()
error message that i get is
ExecuteNonQuery : Connection property has not been initialized.
please help out
thanks
Private Sub Button1_Click_1 (ByVal sender As System.Object, ByVal e As System.EventArg s) Handles Button1.Click
Dim result As Integer
Dim conn As New OleDb.OleDbConn ection("provide r=SQLOLEDB;User ID=sa;password= xxxxxx;Initial Catalog=first;d ata source=NAVEEN;" )
conn.Open()
Dim insert1 As New OleDb.OleDbComm and
insert1 = New OleDb.OleDbComm and("insert into home values('" + TextBox1.Text + "','" + TextBox2.Text + "'),conn")
insert1.Command Type = CommandType.Tex t
result = insert1.Execute NonQuery()
conn.Close()
error message that i get is
ExecuteNonQuery : Connection property has not been initialized.
please help out
thanks
Comment