This is the error I get when I get to the oCmd.ExecuteNonQuery()
ExecuteNonQuery: Connection property has not been initialized.
Everything else looks like it is passing correctly. Any ideas? Below is my code.
Public Sub EditHistory()
If EditOK <> "" Then
Dim DA As New SqlClient.SqlDataAdapter()
Dim oConn As New SqlClient.SqlConnection()
Dim DS As New DataSet()
Dim oCmd As New SqlClient.SqlCommand()
oConn.ConnectionString = "I have hard coded the connection string here"
DA.SelectCommand = New SqlClient.SqlCommand()
DA.SelectCommand.CommandText = "Insert into EditHistory (UserName, TableName, EditAction RecordNumber) VALUES ('" & txtPassword.Text & "','Territory', 'Edit' , '" & TerritoryID & "')"
DA.SelectCommand.Connection = oConn
oConn.Open()
oCmd.ExecuteNonQuery()
oConn.Close()
End If
End Sub
ExecuteNonQuery: Connection property has not been initialized.
Everything else looks like it is passing correctly. Any ideas? Below is my code.
Public Sub EditHistory()
If EditOK <> "" Then
Dim DA As New SqlClient.SqlDataAdapter()
Dim oConn As New SqlClient.SqlConnection()
Dim DS As New DataSet()
Dim oCmd As New SqlClient.SqlCommand()
oConn.ConnectionString = "I have hard coded the connection string here"
DA.SelectCommand = New SqlClient.SqlCommand()
DA.SelectCommand.CommandText = "Insert into EditHistory (UserName, TableName, EditAction RecordNumber) VALUES ('" & txtPassword.Text & "','Territory', 'Edit' , '" & TerritoryID & "')"
DA.SelectCommand.Connection = oConn
oConn.Open()
oCmd.ExecuteNonQuery()
oConn.Close()
End If
End Sub