G
Guest
hi,
this is my first vb.net program.
I'm trying to update an Access database from a DataRow, see code below. It
keeps giving the Error : "Parameter @CustomerDNote has no default value".
Initially I tried without creating a separate oledbconnection.
I'm sure it's something simple that Ive done wrong, but just cant see it.
Thanks
Public Sub EditCreditDetails2(ByVal RowNum As Integer, ByVal ID As Integer,
ByVal strCustDnote As String, ByVal dblCreditValue As Double, ByVal
strCreditNoteNo As String)
Try
Dim con2 As New OleDbConnection
Dim editRow As DataRow =
dstInvoice.Tables("CreditDetails").Rows(RowNum)
Dim sSQL As String
con2.ConnectionString =
System.Configuration.ConfigurationSettings.AppSettings.Get("AccessConnString")
con2.Open()
editRow.BeginEdit()
editRow("CustomerDNote") = strCustDnote
editRow("AmountCredited") = dblCreditValue
editRow("CreditFlag") = True
editRow("DateCredited") = Now
editRow("CreditNote") = strCreditNoteNo
editRow.EndEdit()
sSQL = "UPDATE InvoiceLines SET "
sSQL = sSQL & " CustomerDNote=@CustomerDNote,
AmountCredited=@AmountCredited, "
sSQL = sSQL & "
CreditFlag=@CreditFlag,DateCredited=@DateCredited,"
sSQL = sSQL & " CreditNote=@CreditNote "
sSQL = sSQL & " WHERE InternalID=@InvLineID"
Dim commUpdate As New OleDbCommand(sSQL, con2)
commUpdate.Parameters.Add("@InvLineID", OleDbType.Integer,
Nothing, "InternalID")
commUpdate.Parameters.Add("@CustomerDNote", OleDbType.VarChar,
10, "CustomerDNote")
commUpdate.Parameters.Add("@AmountCredited", OleDbType.Currency,
Nothing, "AmountCredited")
commUpdate.Parameters.Add("@CreditFlag", OleDbType.Boolean,
Nothing, "CreditFlag")
commUpdate.Parameters.Add("@DateCredited", OleDbType.Date,
Nothing, "DateCredited")
commUpdate.Parameters.Add("@CreditNote", OleDbType.VarChar, 10,
"CreditNote")
commUpdate.Connection = New OleDbConnection(con2.ConnectionString)
adpSurcharge.UpdateCommand = commUpdate
adpSurcharge.Update(dstInvoice, "CreditDetails")
Catch eException As Exception
MessageBox.Show(eException.Message)
End Try
End Sub
this is my first vb.net program.
I'm trying to update an Access database from a DataRow, see code below. It
keeps giving the Error : "Parameter @CustomerDNote has no default value".
Initially I tried without creating a separate oledbconnection.
I'm sure it's something simple that Ive done wrong, but just cant see it.
Thanks
Public Sub EditCreditDetails2(ByVal RowNum As Integer, ByVal ID As Integer,
ByVal strCustDnote As String, ByVal dblCreditValue As Double, ByVal
strCreditNoteNo As String)
Try
Dim con2 As New OleDbConnection
Dim editRow As DataRow =
dstInvoice.Tables("CreditDetails").Rows(RowNum)
Dim sSQL As String
con2.ConnectionString =
System.Configuration.ConfigurationSettings.AppSettings.Get("AccessConnString")
con2.Open()
editRow.BeginEdit()
editRow("CustomerDNote") = strCustDnote
editRow("AmountCredited") = dblCreditValue
editRow("CreditFlag") = True
editRow("DateCredited") = Now
editRow("CreditNote") = strCreditNoteNo
editRow.EndEdit()
sSQL = "UPDATE InvoiceLines SET "
sSQL = sSQL & " CustomerDNote=@CustomerDNote,
AmountCredited=@AmountCredited, "
sSQL = sSQL & "
CreditFlag=@CreditFlag,DateCredited=@DateCredited,"
sSQL = sSQL & " CreditNote=@CreditNote "
sSQL = sSQL & " WHERE InternalID=@InvLineID"
Dim commUpdate As New OleDbCommand(sSQL, con2)
commUpdate.Parameters.Add("@InvLineID", OleDbType.Integer,
Nothing, "InternalID")
commUpdate.Parameters.Add("@CustomerDNote", OleDbType.VarChar,
10, "CustomerDNote")
commUpdate.Parameters.Add("@AmountCredited", OleDbType.Currency,
Nothing, "AmountCredited")
commUpdate.Parameters.Add("@CreditFlag", OleDbType.Boolean,
Nothing, "CreditFlag")
commUpdate.Parameters.Add("@DateCredited", OleDbType.Date,
Nothing, "DateCredited")
commUpdate.Parameters.Add("@CreditNote", OleDbType.VarChar, 10,
"CreditNote")
commUpdate.Connection = New OleDbConnection(con2.ConnectionString)
adpSurcharge.UpdateCommand = commUpdate
adpSurcharge.Update(dstInvoice, "CreditDetails")
Catch eException As Exception
MessageBox.Show(eException.Message)
End Try
End Sub