Click here to Skip to main content
15,890,557 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want update the ms access table (stocks) using the data rows in unbound datagridview.
And I run the code I get the error: parameter @Quantity has no default value.

Can somebody help me to sort out this error.

Iam using the following code:



Dim strConnectionString As String = "provider=microsoft.ACE.OLEDB.12.0;DATA SOURCE=C:\BDSM\StoresDB.accdb;"
        Using accConnection As New OleDb.OleDbConnection(strConnectionString)
           Using cmd As New OleDb.OleDbCommand("UPDATE [Stocks] SET Quantity= Quantity - @QuantitySold,TotalCost=TotalCost - @SalesCost where [StockCode]=@Param1 ", accConnection)
              cmd.Parameters.AddWithValue("@QuantitySold", row.Cells("Quantity").Value)
              cmd.Parameters.AddWithValue("@SalesCost", row.Cells("TotalCost").Value)
              cmd.Parameters.AddWithValue("@Param1", row.Cells("StockCode").Value)
              accConnection.Open()

              Dim intUpdate As Integer = cmd.ExecuteNonQuery()
              accConnection.Close()
           End Using
        End Using
     Next


What I have tried:

I have tried to check the datatypes in the database.
Posted
Comments
Richard MacCutchan 23-Sep-17 5:05am    
Look at the line where the error occurs and see why it does not have a value.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900