hello press save, i got and error and said ExecuteNonQuery: Connection property has not been initialized.
Here's the code:

Private Sub cmdSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSave.Click
        Dim com As New OleDbCommand
        com.Connection = con
        com.CommandText = "insert into Sales values('" & txtSalesId.Text & "','" & txtCustomerId.Text & "','" & _
                            txtWatchId.Text & "','" & txtDate.Text & "'," & txtQuantity.Text & "," & txtAmount.Text & ")"
        com.ExecuteNonQuery()
        MsgBox("Record Inserted")
        Call populateCustomer()
        Call populateWatch()
    End Sub

Please any1 correct my statement
thanks

>Connection property has not been initialized.
Connection string is empty.

Dim com As New OleDbCommand
 Dim con as New OleDBConnection
 con.ConnectionString="Put_connection_string_here"
 com.Connection = con
 com.CommandText = "insert into Sales values('" & txtSalesId.Text & "','" & txtCustomerId.Text & "','" & _
                            txtWatchId.Text & "','" & txtDate.Text & "'," & txtQuantity.Text & "," & txtAmount.Text & ")"
  con.Open()
        com.ExecuteNonQuery()
    con.Close()
    ...
        MsgBox("Record Inserted")
        Call populateCustomer()
        Call populateWatch()
   ...

>Connection property has not been initialized.
Connection string is empty.

Dim com As New OleDbCommand
 Dim con as New OleDBConnection
 con.ConnectionString="Put_connection_string_here"
 com.Connection = con
 com.CommandText = "insert into Sales values('" & txtSalesId.Text & "','" & txtCustomerId.Text & "','" & _
                            txtWatchId.Text & "','" & txtDate.Text & "'," & txtQuantity.Text & "," & txtAmount.Text & ")"
        com.ExecuteNonQuery()
    con.Close()
    ...
        MsgBox("Record Inserted")
        Call populateCustomer()
        Call populateWatch()
   ...

Don't forget to open the connection before executing the query ;)

con.Open()
Comments
Thanks Simon.
This question has already been answered. Start a new discussion instead.