zendog1960
Member
- Joined
- Jan 9, 2008
- Messages
- 19
- Programming Experience
- Beginner
First off let me state that I am learning the database areas of Winforms and how they all relate to each other so my knowledge is somewhat limited.
Here are the current conditions:
I created a database within the project which includes the following fields:
Database Name: Cigarettes.mdf
ItemID - Primary Key
SamCode - ordering code nothing special
FullName - Products Full Name
UPCnumber - UPC on product
OnHand - product actually in store
Reorderlevel - number set where is onhand is lower, it is time to order
OrderQty - Computed Column
The OrderQty has the following computation:
I also have a dataset named CigarettesDataSet with all fields included
In my form I have the following controls:
CigarettesDataGridView
CigarettesBindingNavigator
ComboBox1 - Populated by DataBound CigaretteSourceBinding1
Button1 - Sets Filter of grid to = current combobox1.text value
Button2 - Resets grid to show all records
The form works great for filtering and looking at all the records.
Here is the problem. When I update existing records or add new records then hit the save button on the CigarettesBindingNavigator the application throws this exception:
The column "OrderQty" cannot be modified because it is either a computed column or is the result of a UNION operator.
I know this is because the OrderQty is a computed column. can someone please help with a way to update the database and have the database compute the OrderQty as intended? Is this possible?
The code for the current update is:
Any help would be greatly appreciated
Thanks
Here are the current conditions:
I created a database within the project which includes the following fields:
Database Name: Cigarettes.mdf
ItemID - Primary Key
SamCode - ordering code nothing special
FullName - Products Full Name
UPCnumber - UPC on product
OnHand - product actually in store
Reorderlevel - number set where is onhand is lower, it is time to order
OrderQty - Computed Column
The OrderQty has the following computation:
VB.NET:
(case when ([ReorderLevel]-[OnHand])<(0) then (0) else [ReorderLevel]-[OnHand] end)
I also have a dataset named CigarettesDataSet with all fields included
In my form I have the following controls:
CigarettesDataGridView
CigarettesBindingNavigator
ComboBox1 - Populated by DataBound CigaretteSourceBinding1
Button1 - Sets Filter of grid to = current combobox1.text value
Button2 - Resets grid to show all records
The form works great for filtering and looking at all the records.
Here is the problem. When I update existing records or add new records then hit the save button on the CigarettesBindingNavigator the application throws this exception:
The column "OrderQty" cannot be modified because it is either a computed column or is the result of a UNION operator.
I know this is because the OrderQty is a computed column. can someone please help with a way to update the database and have the database compute the OrderQty as intended? Is this possible?
The code for the current update is:
VB.NET:
Private Sub CigarettesBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CigarettesBindingNavigatorSaveItem.Click
Me.Validate()
Me.CigarettesBindingSource.EndEdit()
Me.TableAdapterManager.UpdateAll(Me.CigarettesDataSet)
End Sub
Any help would be greatly appreciated
Thanks