Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Connection property has not been initialized

Status
Not open for further replies.

Dross

Programmer
Aug 16, 2001
212
US
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 <> &quot;&quot; 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 = &quot;I have hard coded the connection string here&quot;

DA.SelectCommand = New SqlClient.SqlCommand()
DA.SelectCommand.CommandText = &quot;Insert into EditHistory (UserName, TableName, EditAction RecordNumber) VALUES ('&quot; & txtPassword.Text & &quot;','Territory', 'Edit' , '&quot; & TerritoryID & &quot;')&quot;

DA.SelectCommand.Connection = oConn
oConn.Open()
oCmd.ExecuteNonQuery()
oConn.Close()
End If
End Sub

 
Is it that

DA.SelectCommand.CommandText

should be...

DA.InsertCommand.CommandText

...just a shot in the dark...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top