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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T12:56:59+00:00 2026-06-10T12:56:59+00:00

I have a SQL Server with a roster/information. I would like to update the

  • 0

I have a SQL Server with a roster/information. I would like to update the table with situps, pushups, and Id. I know how to insert information into a table, but having trouble with the Update part of it.

Here is my code:

SqlConnection conns = new SqlConnection(ConfigurationManager.ConnectionStrings["TestDBConnectionString1"].ConnectionString);
SqlCommand cmd = new SqlCommand("UPDATE test SET SitUps = @SitUps, pushUps = @pushUps WHERE (Id = @Id)", conns);
cmd.CommandType = CommandType.Text;

Label sitL = ((Label)FormView2.FindControl("SitUpsLabel"));
Label pushL = ((Label)FormView2.FindControl("pushUpsLabel"));
Label IdL = ((Label)FormView2.FindControl("IdLabel"));

cmd.Parameters.AddWithValue("@SitUps", sitL.Text);
cmd.Parameters.AddWithValue("@pushUps", pushL.Text);
cmd.Parameters.AddWithValue("@Id", IdL.Text);

I’m getting this error

System.NullReferenceException: Object reference not set to an
instance of an object.

I’m pretty sure it’s the way I’m treating the Id value. Thanks in advance!!

  • 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-10T12:57:00+00:00Added an answer on June 10, 2026 at 12:57 pm
    1. Ensure that the 3 id that you stated there, “SitUpsLabel”, “pushUpsLabel” and “IdLabel” is the same as what you have on the form view.

    2. I noticed that “IdL” color is odd, try using other variable name instead. You could be using “IdL” for some other purposes.

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

Sidebar

Related Questions

I have SQL Server 2008 with a table called ProductCategories designed like this: Id
I only have SQL Server 2008 Client tools. I would like to use Spy++
I have SQL Server database and would like to use LINQ to Entities and
I have SQL Server Compact 3.5 database that contains account information. But everytime I
I have Sql Server database and i would like to export the data as
I have SQL Server 2005 and I am trying to export a table into
I have SQL server 2000 dev edition. But it isn't compatible with my new
I have SQL Server 2008. I run a query in a table on a
I have SQL Server data base where i am storing city Name. Like Delhi;
I have sql server 2008 db table FILE_DETAILS in following format. ID FileName Filesize_in_MB

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.