how to insert totalprice value to access database
-
im using vb. To summarize, i have a textbox where user input quantity and a gridview to display the price. i also have a submit button to calculate the totalprice where totalprice = quantity * price. meanwhile im using a label to store the value price.
Dim tmp As Double = e.Row.Cells(3).Text.Trim Label1.Text = "$" + (tmp).ToString("0.00")
this is the submit codingmyCommand.CommandText = "INSERT INTO [Order] ([Quantity], [TotalPrice]) VALUES ('" & CStr(Me.txtQty.Text) & "',__________)" is ________ me.txtQty * Label.Text ?? i need to know what should be the correct way.
thanks in advance. Much appreciated.
-
im using vb. To summarize, i have a textbox where user input quantity and a gridview to display the price. i also have a submit button to calculate the totalprice where totalprice = quantity * price. meanwhile im using a label to store the value price.
Dim tmp As Double = e.Row.Cells(3).Text.Trim Label1.Text = "$" + (tmp).ToString("0.00")
this is the submit codingmyCommand.CommandText = "INSERT INTO [Order] ([Quantity], [TotalPrice]) VALUES ('" & CStr(Me.txtQty.Text) & "',__________)" is ________ me.txtQty * Label.Text ?? i need to know what should be the correct way.
thanks in advance. Much appreciated.
Plz try this cdbl(me.txtQty.text) * cdbl(Label.Text ) or cint(me.txtqty.text) * cint(Lable.Text) Your access database column type should be integer, Float or Double.... Quantity,TotalPrice. Better way......... dim Total as integer = cint(me.txtqty.text) * cint(Lable.Text) "Insert Into order (quantity,TotalPrice) Values (" & me.txtQty.Text & "," & cstr(Total) & ")"
Parwej Back...............DON of Developer....... Parwej Ahamad g_parwez@rediffmail.com
-
Plz try this cdbl(me.txtQty.text) * cdbl(Label.Text ) or cint(me.txtqty.text) * cint(Lable.Text) Your access database column type should be integer, Float or Double.... Quantity,TotalPrice. Better way......... dim Total as integer = cint(me.txtqty.text) * cint(Lable.Text) "Insert Into order (quantity,TotalPrice) Values (" & me.txtQty.Text & "," & cstr(Total) & ")"
Parwej Back...............DON of Developer....... Parwej Ahamad g_parwez@rediffmail.com
thanks but there was an error No value given for one or more required parameters.
Dim Total As Integer = CInt(Me.txtQty.Text) * CInt(Label1.Text) myCommand.CommandText = "INSERT INTO [Ord] ([Quantity], [TotalPrice]) VALUES ('" & CStr(0) & "','" & CStr(Total) & "')"
i change my databse for TotalPrice to number instead of currency.thanks in advance. Much appreciated.
-
thanks but there was an error No value given for one or more required parameters.
Dim Total As Integer = CInt(Me.txtQty.Text) * CInt(Label1.Text) myCommand.CommandText = "INSERT INTO [Ord] ([Quantity], [TotalPrice]) VALUES ('" & CStr(0) & "','" & CStr(Total) & "')"
i change my databse for TotalPrice to number instead of currency.thanks in advance. Much appreciated.
The error message means that you have one or more names in the query that doesn't match the database. Check the name of the table and the names of the fields. If the fields are numeric, you should not use apostrophes around the values, as that makes them string values. Why are you storing the total price in the database anyway? If you display the data later, don't you want to display both the price and the total price? You can always calculate the total price if you store the price and the quantity, but if you store the total price and quantity you have to re-create the price, which is a bit backwards.
--- Year happy = new Year(2007);
-
The error message means that you have one or more names in the query that doesn't match the database. Check the name of the table and the names of the fields. If the fields are numeric, you should not use apostrophes around the values, as that makes them string values. Why are you storing the total price in the database anyway? If you display the data later, don't you want to display both the price and the total price? You can always calculate the total price if you store the price and the quantity, but if you store the total price and quantity you have to re-create the price, which is a bit backwards.
--- Year happy = new Year(2007);
in detail, i have two tables, 1 is products details and the other is order details. so the totalprice n quantity are meant for the order details table. so how should i solve the problem? both the field names are spelled correctly.
thanks in advance. Much appreciated.
-
in detail, i have two tables, 1 is products details and the other is order details. so the totalprice n quantity are meant for the order details table. so how should i solve the problem? both the field names are spelled correctly.
thanks in advance. Much appreciated.
blurMember wrote:
in detail, i have two tables, 1 is products details and the other is order details. so the totalprice n quantity are meant for the order details table.
I see. You might consider copying the price from the products table to the order table at the time of the order, so that the orders doesn't change if the product changes.
blurMember wrote:
both the field names are spelled correctly.
The database begs to differ... ;) Debug the application and look at the query that you created, so that you see if it ended up the way that you expect.
--- Year happy = new Year(2007);