Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6071535
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:03:30+00:00 2026-05-23T10:03:30+00:00

I have table with items: id | title | ordersTillNow I want to write

  • 0

I have table with items:

id | title | ordersTillNow

I want to write c# code on the button click event so that after the customer clicks on purchase button the column ordersTillNow will increase by one (++)…

Can this be done with Linq-to-SQL ? Or with SqlCommand?

Anyway …how can I do that on c# (code behind, with Linq-to-SQL or SqlCommand) ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T10:03:30+00:00Added an answer on May 23, 2026 at 10:03 am

    Assuming you’re using Linq-to-SQL, you will have a data context for your database, and an object that represents your table.

    When the customers click, you’d write code something like this:

    using (YourDataContext ctx = new YourDataContext())
    {
        Customer myCust = from c in ctx.Customers
                          where c.CustomerId == ID
                         select c;
    
        myCust.ordersTillNow++;
        ctx.SubmitChanges()
    }
    

    Using a SqlCommand, you have lots of options to do this – a stored procedure, inline SQL – whatever.

    You’ll write code something like this:

    string updateStmt = "UPDATE dbo.YourTable SET ordersTillNow = ordersTillNow + 1 " +
                        "WHERE CustomerID = @CustomerID";
    
    using(SqlConnection _conn = new SqlConnection("your-connection-string-here"))
    using(SqlCommand _cmd = new SqlCommand(_conn, updateStmt))
    {
       _cmd.Parameters.Add("@CustomerID", SqlDbType.Int).Value = yourCustomerID;
       _conn.Open();
       _cmd.ExecuteNonQuery();
       _conn.Close();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

let's say that I have a table called Items (ID int, Done int, Total
I'm kind of stumped. I have a table of items with fields: ID, title,
I have a table in phpmyadmin that stores an 'id' (auto inc), 'title' and
Say for example I have this table: Items: ------- id title price And I
i have this three tables. Table: Item Columns: ItemID, Title, Content, NoChange (Date) Table:
I have a table Users and a table Items In the Items table, I
I'm working on a very basic shopping cart system. I have a table items
I have a table of items, and a table of itemkeywords. When a user
I have a table of items, each of which has a date associated with
I have a table of items. item has id, score 1, score 2. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.