C# - Updating The Quantity Through SQL?

Dec 6, 2010

I posted a question earlier about updating the quantity column in my table, I use the code found below however I think because the Select and Update is inside of a foreach loop it is updating all of the products.

Furthermore, the products are also updated when the page is reloaded and the amount is increased based on how many times the user clicks on the add button. E.g. Click the add button twice the quantity increments by two each time.

I ideally need to be able to use the ItemID outside of the foreach loop, but can't.

Code:

foreach (UserItem ItemID in (List<UserItem>)Session["UserSession"])
{
ConclusionPage.InsertCommand = "IF EXISTS (SELECT ItemID FROM tblUserItems WHERE UserID='@CurrentUser' AND ItemID='@ItemID') UPDATE tblUserItems SET Quantity = Quantity+1 WHERE (UserID = '@CurrentUser') AND (ItemID = '@ItemID')";
ConclusionPage.Insert();
}

View 2 Replies


Similar Messages:

Web Forms :: Get RefNo From Three Table With Sum Of Quantity?

Apr 29, 2010

1) I have a Requirment where i have to get the Refno with Quantity from master table and which is not available in any of three table.. for Ex: TableA,TableB,TableC and then one more if Refno is available then.. have to sum from three table which it has the refno.... up to i need to show when MasterItem Refno with Quantity is not equal.. once it become equal from three table will not show the refno...

View 3 Replies

Web Forms :: Show Quantity In ListBox?

Apr 27, 2012

is it possible to select only the item that are displayed in the list box. That is i am having a list of item starting from 0 to 100 in the list box. But i have reduced the height of the list box so that it displayed the item one by one. I need the displayed item to automatically selected.

View 1 Replies

Summarizing Quantity Using 2 Separate Date Ranges

Mar 10, 2011

Perhaps someone has done something like this before. I am generating a quantity summary report. The quantities have to be summarized in two ways:A quantity for a specified date range, which can fall anywhere within the project duration defined by the user provided UserStartDate and UserEndDate A Quantity to date, defined by the ProjectStartDate till the user defined UserEndDate So if I put all these dates in sequence it would look something like this: ProjectStartDate, UserStartDate, UserEndDate, ProjectEndDate Right now in the code the User specified dates are vStartDate and vEndDate. The source data (list of bid items) is compiled in a UNION query (SqlServer View) and I am querying from this view using a stored procedure from which the data is captured using the code below.

Public Shared Function GETeFieldQuantityData( _
ByVal vProjectNo As String, _
ByVal vStartDate As DateTime, _
ByVal vEndDate As DateTime) _
As IEnumerable
' Dim SqlConnection, SqlCommand, and SqlDataReader
Dim vSqlConn As SqlConnection = New SqlConnection(GetConnString)
Dim vSqlCmd As SqlCommand = New SqlCommand("eFieldReturnQuantitySummary", vSqlConn)
'Dim vDataRdr As SqlDataReader
vSqlConn.Open()
'Construct parameters
vSqlCmd.Parameters.AddWithValue("@StartDate", vStartDate)
vSqlCmd.Parameters.AddWithValue("@EndDate", vEndDate)
vSqlCmd.Parameters.AddWithValue("@ProjectNum", vProjectNo)
vSqlCmd.CommandType = CommandType.StoredProcedure
'Return SqlDataReader Object
Return vSqlCmd.ExecuteReader(CommandBehavior.CloseConnection)
End Function
And the SELECT statement returning data to the form:

Code:

SELECT BidItemDesc As [Bid Item Description], Unit,
SUM(Qty) AS [Tot Qty], COUNT(*) AS Records
FROM dbo.qryQuantityWorkSheet
WHERE ((ProjectNum = @ProjectNum)
AND (ProjDate >= @StartDate)
AND (ProjDate <= @EndDate) )
GROUP BY ProjectNum, BidItemDesc, Unit
ORDER BY BidItemDesc

View 4 Replies

Web Forms :: Unable To Change A Quantity On Any Variant Besides The First One?

Jun 25, 2010

I have a shooping cart in version 9.0.1.3

I have several products with two variants for each.

I can add any quanity to the first variant and it is calculated into the cart correctly.

When I try to add a number besides one for the second variant it will only show one of the porduct in the cart.

I can change the quanity when it is in the cart. But I need it to work correctly.

View 3 Replies

Crystal Reports :: Conditional Sum QUANTITY----PAID_DAY ?

Mar 31, 2011

In crystal report, for data showing at below:

QUANTITY----PAID_DAY

12------------2/2/2010

35------------

63------------5/15/2010

13------------

How to add code to sum of Quantity if there is a day in [PAID_DAY]?

The result showing on the report should be 12+63=75.

View 2 Replies

Deal With The Quantity Column Of A Junction Table Using Sql To Entities?

Feb 2, 2010

I have 3 tables. Blog and Tag have a many to many relationship. BlogTag is a junction table with a quantity column.

**Blog**
BlogID
Title
**Tag**
TagID
Name
**BlogTag**
BlogID
TagID
Quantity

I'm not sure how I handle the quantity column. I'd like it to store how many Blogs have a certain Tag NameHow do I deal with the quantity column when adding a new blog that has tags?

View 1 Replies

DataSource Controls :: How To Calculate The Total Quantity Demanded By A Particular Customer

Mar 22, 2010

We have a demand system where customer can demand the quantity they want for a particular deal.

For each demand they submit, a new record is added to the DealDemandRequest table with the CustomerID, DealID, Quantity

I want to be able to to calculate the total quantity demanded by a particular customer. Current I query the DealDemandRequest table for all the records by a particular customer and then do a sum of the Quanity column.

However, we are expecting this table to be over 1 million record and it is reallly really slow right now.. Any better ways?

View 3 Replies

Forms Data Controls :: ListView Display Products Quantity?

Sep 19, 2010

I'd like show a products list in one ListView. Each item is a product in the List<Productos>.

If a product quantity is 3, the list have 3 repeated items with the same product.

How can i do for display in the item of ListView the product description + quantity of this product?

This is my code:

[Code]....

View 7 Replies

Web Forms :: Find Total Quantity In GridView Shopping Cart

Jun 19, 2012

String conn = System.Configuration.ConfigurationManager.ConnectionStrings["conString"].ConnectionString;
SqlConnection con = new SqlConnection(); // for connection
SqlDataAdapter adp = new SqlDataAdapter(); // for fetch the records acc. to condition
DataTable dt = new DataTable(); // fill the fetched records
DataTable tb; // will store the session

[Code] .....

How will I get the total number of quantity....

View 1 Replies

Forms Data Controls :: Get The Label ExtPrice To Display The Quantity Entered?

Feb 28, 2010

I am trying to have a gridview row update a label in that gridview with the results of a calculation.

Eg. qty ordered * Price = lineTotal

I have:

[code]....

How do I get the Label extPrice to display the quantity entered * the price?

View 4 Replies

AJAX :: How To Update The Amount Column When Change The Value Of Quantity And Price In Gridview!

Mar 30, 2011

I have an ASP.NET gridview that list all data rows for Book store with column name: Book (BoundField), quantity (TemplateField) , price (templateField) and amount (amount = quantity * price). I would like to change either quantity or price that will update the amount automatically after leaving cell in the gridview but not save new values into database until I made all changes and display message: "Are you sure to change them in database?".

View 1 Replies

Forms Data Controls :: Add New Column In Gridview - Where The User Can Enter The Quantity

Nov 26, 2010

I list selections of available items in a gridview and have added a button column for adding items to a cart. Is there a way to add a column where the user can enter the quantity to add?

View 1 Replies

Forms Data Controls :: Update Row After Increasing Quantity Doesn't Work?

Jan 1, 2010

see my jpg picture to identify problem easly

[URL]

when i change quantity up it s increasing 1 but sum doesnt increasing if i click twice its increasing but wrong where i am doing wrong

my code is

[Code]....

View 5 Replies

Forms Data Controls :: Calculate Inside Gridview Amount=price*quantity?

Oct 28, 2010

In my webpage i am trying to create a order by gridview here item selected by user from dropdown and on selction of dropdown price display in next to item dropdown label price.now user insert quantity from next grid textbox and next is label amount shold disply calculate amount on price and quantity.i also want to use javascript for this prob.what i did that item and price displaying and user make input from textbox now want to calculation but how textbox recieve input and amount label dispaly calculate amount.

[Code]....

View 1 Replies

Forms Data Controls :: Calculate To Current Rowafter Update Quantity But Other Rows Don't Affect And Not Calculate

Jan 6, 2010

my code is calculate to current rowafter update quantity but other rows don't affect and not calculate i need to calculate all rows i think i need to use for loops but i dont know how to do it

[code]....

[Code]....

View 7 Replies

Using App_offline.htm To Take An App Offline While Updating Dll's Fails While Updating Dll's?

Sep 17, 2010

So I sometimes use app_offline.htm to take an app offline while I upload a new version.However, while I am in the process of uploading larger dll's, I get the yellow error-screen saying the dll could not be loaded.This seems to be out of sync with my expectations of what app_offline.htm does (stops the app entirely), and also provides the users with errors in stead of the nice app_offline.htm I put up.Am I doing something wrong or is this behavior by design?

View 1 Replies

C# - Updating My Database?

Jan 4, 2011

I am new with the subsonic, and I have a problem when trying to update the database from the sql server. I have created a gridview by still is not returning the updates results. can you please help me? its getting an error code on dc.AddMostaHse();
(Cannot implicity convert type 'void to 'object')

Here is the code being done of DataAccess.cs page

public void AddMostaHse()
{

Mosta.MostaHSE1 xx = new MostaHSE1();
[code]..

View 2 Replies

ADO.NET :: Row Updating In A Gridview?

Feb 23, 2011

I am updating values in a gridview below is my code [Code]....

but whenever i update the value it is not getting updated in the database and it is not showing any error.

View 3 Replies

Updating GUI Before Redirect?

Oct 5, 2010

I have a GUI that contains several components (combo boxes, textboxes, etc) with their associated labels. When a button is pressed, the selection in each input component is validated, and if found to contain an invalid value, the label color changes to red and an error message appears. This works fine on its own.

The problem arises when invalid values are provided and then later fixed. When the user presses the button and the inputs are valid, I redirect the response to an asp using Response.Redirect, which then runs and opens a PDF report. When this happens, none of the code to change the labels back to their original color or to remove the error message runs. If I change Response.Redirect() to Server.Transfer() and the user goes back, it returns the page to its original state (removing the error messages), but I want to keep the valid data in each component.

What can I do to either remove the error messages when the user goes back or to retain the valid input from the user?

EDIT: Most of the controls are non-standard .NET controls and I'm working with VB.NET 2003.

View 1 Replies

Updating Db With Textbox Does Not Work?

Mar 8, 2010

I've been trying to resolve this issue for like 10 hours but with no luck. I am trying to load data from a db to text boxes and allow the user to enter his/her modifications and click a button to update the db with the entered value in the textboxes. The problem is the entered data are not sent to the db but the data that are loaded when the page is loaded is what it goes to the db. I also tried vb codes and javascript to change the data of the textbox but that did not work.

here is my code:

[Code]...

View 4 Replies

Updating Database From Textbox?

Apr 5, 2010

I am trying to update the table records by intering a new values in a textbox

and am facing problems in the code of dataset

how could I perform that

[code]....

You should post any code that you are having problems with in the thread (because apparently some people can't open the files attached).

Anyways, you need a TextBox on the page. Then you need to access the Text in the TextBox (using the TextBox.Text property). Once you've got that you should use it to update your database.

The best way to supply this value (that has been provided by the end user) is to use the SqlCommand.Parameters property (if you're using the SqlCommand object).

This topic is covered nicely in:

How to use database in your program Part 1
How to use database in your program Part 2

View 3 Replies

Updating Placeholder During Runtime?

Mar 11, 2010

I have a repeater and within that repeater, I have an item template. Now this template is formatted with a couple of tables, but for this question I have removed them to make things easier to read:

[code]....

View 1 Replies

C# - GridView Isn't Updating Properly

Sep 14, 2010

I have a Gridview with these parameters:

<asp:GridView runat="server" ID="ItemGrid" CssClass="Grid"
AutoGenerateColumns="false"
AutoGenerateDeleteButton="true" OnRowDeleting="RowDeleting"
AutoGenerateEditButton="true" onRowEditing="RowEdit"
OnRowCancelingEdit="CancelRowEdit" onRowUpdating="RowUpdating"
DataKeyNames="Item_ID">
<Columns>
<asp:BoundField HeaderText="Item" DataField="Item"/>
<asp:BoundField HeaderText="Family" DataField="Family"/>
<asp:BoundField HeaderText="Structure" DataField="Structure"/>
<asp:BoundField HeaderText="Updated" ReadOnly="true" DataFormatString="{0:d}" DataField="Updated"/>
</Columns>
</asp:GridView>


On updating it calls:

protected void RowUpdating(object sender, GridViewUpdateEventArgs e){
int Item_ID = (int)this.ItemGrid.DataKeys[e.RowIndex][0];[code]...

It generates the Update/Edit/Delete buttons, my Delete function is working exactly how I want and the 'Edit' button generates editable TextBoxes as it should.

My problem is in the updating part, the strings Item, Family, Structure are getting the old values, not the new values I put in the generated text boxes.If I hard code in values they are updated to the database and the DateTime.Now is always updating correctly in the database so the update query is working.

I've been looking at this/reading forums testing things for a couple days now. I'm sure I'm just missing something simple that I have overlooked.

Edit:It has been answered but for those who were curious this is my dataBind();

protected void dataBind()
{
ItemTableAdapter taItem = new ItemTableAdapter();
this.ItemGrid.DataSource = taItem.GetActive();
this.ItemGrid.DataBind();
}

View 3 Replies

C# - Updating Different Parts Of An MVC Page At Once?

Jan 16, 2010

i want to update different areas of my MVC page after one action (say a click) occurs.

how, i use ajax, and wrapping the entire area where all these parts need to be updated is counter intuitive as the ajax data being sent back would be close to the entire page.

so, i have a few partial views, - but the problem is, each action only returns one view! how can i return multiple views from this one action?

i know a popular solution is to just hammer the server with multiple async javascript ajax requests for each "part" of the view, but this really is unnecessary and inefficient, reconstructing and destroying the page (say) 5 times for just one action, when it should just occur once, and once it does, the server should manage all the partial views then and there.

View 3 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved