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 8103801
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T23:39:19+00:00 2026-06-05T23:39:19+00:00

I have an ASP.NET project connecting to a database. A web page sends a

  • 0

I have an ASP.NET project connecting to a database. A web page sends a query to the database. More than one, as a matter of fact, it reads from database successfully.
On click of a submit button I send an UPDATE query to the SQL Server (2008).

I work with C#, sending the UPDATE query to the server with a SqlCommand object initialized as such:

Edit: Added variables to query.

string strQuery = "UPDATE [tbl] SET [f1]='" + stringValue + "', [f2]='" + (boolValue?"1":"0") + "' WHERE [id]=" + intId.ToString() + ";";
SqlCommand cmd = new SqlCommand(strQuery, connectionObject);
int QueryResult = cmd.ExecuteNonQuery();

QueryResult ends up 0, and, of course, no change done. Copy-Paste to SSMS – I get 1 row(s) affected and the data changes.

Connection works fine – when I use this to check the work on the DB – the query has been executed. (It looks something like (@1 varchar(8000), @2 varchar(8000), @3 tinyInt) UPDATE [tbl] SET [f1]=@1, [f2]=@2 WHERE [id]=@3;).

Any idea what’s going on – appreciated.
Thank you!

  • 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-06-05T23:39:20+00:00Added an answer on June 5, 2026 at 11:39 pm

    The most likely thing is that the WHERE [id]=" + intId.ToString() isn’t finding the row to be updated.

    Either this is because:

    • The ID is correct and the row doesn’t exist yet (if you’re inserting it just before hand)
    • The ID is wrong
    • stringValue contains something that is corrupting your SQL such that it executes but matches nothing (unlikely but possible).
    • You’re not executing the SQL against the right database (I’ve done this before in Dev environments with multiple dbs around!)

    If you put a breakpoint on the line after the strQuery assignment see what it contains, and maybe post its contents back into your question.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an ASP.NET project which is a front-end to a database. In addition
I have an ASP.NET project which has already some custom fields in it's web.config
We have an ASP.Net MVC project that will start with a single web server
in my asp.net MVC project i have an database connection with connectionstring: Data Source=.;Initial
I have a C#/ASP.net project has included a database that I have developed that
I Have an asp.net web service that uses an oracle database. It works when
I have a ASP.NET project and PostgreSQL database. In my database, I have table
I have the following project solution: There is a ASP.NET MVC Web Application where
I have an ASP.NET MVC project that uses a SQL Server Compact database. I
I have the correct entries in the web.config file in my ASP.NET project. How

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.