Hello,
I am trying to update a link table with values from multiple datagrids, the field types in the link table are numbers and the value selected from the datagrids are also numbers.
I am getting the following error:
The OleDbParameterCollection only accepts non-null OleDbParameter type objects, not String objects.
In line : cmdCompany.Parameters.Add("@COMPANY_ID")
Any ideas on how to fix this error?
Thanks in advance
Victor
Code:
Dim ConnectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\aop29.mdb"
Dim cmdCompany As OleDbCommand
Dim cmdReceiver As OleDbCommand
Dim CompanySQL As String
Dim ReceiverSQL As String
Dim objConnection As New OleDb.OleDbConnection(ConnectionString)
Dim Trans As OleDbTransaction
CompanySQL = "INSERT INTO Link_TableA(CALIBER_ID) VALUES(@Company_ID)"
cmdCompany = New OleDbCommand(CompanySQL, objConnection)
cmdCompany.Parameters.Add("@Company_ID") *****ERROR LOCATION
cmdCompany.Parameters("@Company_ID").Value = C1TrueDBGrid1.Columns(0).Value
ReceiverSQL = "INSERT INTO Link_TableA(Receiver_ID) VALUES(@Receiver_ID)"
cmdReceiver = New OleDbCommand(ReceiverSQL, objConnection)
cmdReceiver.Parameters.Add("@Receiver_ID")
cmdReceiver.Parameters("@Receiver_ID").Value = C1TrueDBGrid2.Columns(0).Value
Try
Trans = objConnection.BeginTransaction
cmdCompany.Transaction = Trans
cmdCompany.ExecuteNonQuery()
cmdReceiver.Transaction = Trans
cmdReceiver.ExecuteNonQuery()
Trans.Commit()
Catch ex As Exception
an error occurred, so rollback the transaction
If Not Trans Is Nothing Then
Trans.Rollback()
End If
MsgBox("Error saving data.")
MsgBox(ex.Message)
End Try
I am trying to update a link table with values from multiple datagrids, the field types in the link table are numbers and the value selected from the datagrids are also numbers.
I am getting the following error:
The OleDbParameterCollection only accepts non-null OleDbParameter type objects, not String objects.
In line : cmdCompany.Parameters.Add("@COMPANY_ID")
Any ideas on how to fix this error?
Thanks in advance
Victor
Code:
Dim ConnectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\aop29.mdb"
Dim cmdCompany As OleDbCommand
Dim cmdReceiver As OleDbCommand
Dim CompanySQL As String
Dim ReceiverSQL As String
Dim objConnection As New OleDb.OleDbConnection(ConnectionString)
Dim Trans As OleDbTransaction
CompanySQL = "INSERT INTO Link_TableA(CALIBER_ID) VALUES(@Company_ID)"
cmdCompany = New OleDbCommand(CompanySQL, objConnection)
cmdCompany.Parameters.Add("@Company_ID") *****ERROR LOCATION
cmdCompany.Parameters("@Company_ID").Value = C1TrueDBGrid1.Columns(0).Value
ReceiverSQL = "INSERT INTO Link_TableA(Receiver_ID) VALUES(@Receiver_ID)"
cmdReceiver = New OleDbCommand(ReceiverSQL, objConnection)
cmdReceiver.Parameters.Add("@Receiver_ID")
cmdReceiver.Parameters("@Receiver_ID").Value = C1TrueDBGrid2.Columns(0).Value
Try
Trans = objConnection.BeginTransaction
cmdCompany.Transaction = Trans
cmdCompany.ExecuteNonQuery()
cmdReceiver.Transaction = Trans
cmdReceiver.ExecuteNonQuery()
Trans.Commit()
Catch ex As Exception
an error occurred, so rollback the transaction
If Not Trans Is Nothing Then
Trans.Rollback()
End If
MsgBox("Error saving data.")
MsgBox(ex.Message)
End Try