Systematic
Member
- Joined
- May 8, 2013
- Messages
- 6
- Programming Experience
- Beginner
Please Help am having this error: "ExecuteNonQuery: Connection property has not been initialized"
Imports System.Data.SqlClient
Public Class Form1
Dim cm As New SqlConnection("Data Source=KHQ01WX12F4;Initial Catalog=VEHICLEDATA;User ID=sa;Password=MasaPIMS2008")
Dim cmd As New SqlCommand
Dim dr As SqlDataAdapter
Private Sub SAVE_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SAVE.Click
cm.Open()
cmd.CommandText = "insert into tblMyDetails (DateOpened,ourRef) values ('" & txtName.Text & "','" & txtSurname.Text & "')"
cmd.ExecuteNonQuery()
MessageBox.Show("Record saved Successfully")
cm.Open()
End Sub
End Class
Imports System.Data.SqlClient
Public Class Form1
Dim cm As New SqlConnection("Data Source=KHQ01WX12F4;Initial Catalog=VEHICLEDATA;User ID=sa;Password=MasaPIMS2008")
Dim cmd As New SqlCommand
Dim dr As SqlDataAdapter
Private Sub SAVE_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SAVE.Click
cm.Open()
cmd.CommandText = "insert into tblMyDetails (DateOpened,ourRef) values ('" & txtName.Text & "','" & txtSurname.Text & "')"
cmd.ExecuteNonQuery()
MessageBox.Show("Record saved Successfully")
cm.Open()
End Sub
End Class