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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T20:22:51+00:00 2026-06-12T20:22:51+00:00

Microsoft’s own documentation provides an example of deleting a record as follows: // Create

  • 0

Microsoft’s own documentation provides an example of deleting a record as follows:

// Create the DeleteCommand.
command = new SqlCommand(
    "DELETE FROM Customers WHERE CustomerID = @CustomerID", connection);

// Add the parameters for the DeleteCommand.
parameter = command.Parameters.Add(
    "@CustomerID", SqlDbType.NChar, 5, "CustomerID");
parameter.SourceVersion = DataRowVersion.Original;

adapter.DeleteCommand = command;

But on my system it doesn’t work (complaining about missing @CustomerID). Instead, if I replace the

command.Parameters.Add("@CustomerID", SqlDbType.NChar, 5, "CustomerID");

above with

command.Parameters.AddWithValue("@CustomerID", 5);

It works.

Why?

  • 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-12T20:22:52+00:00Added an answer on June 12, 2026 at 8:22 pm

    In this line:

    command.Parameters.Add("@CustomerID", SqlDbType.NChar, 5, "CustomerID");
    

    In this overload, 5 refers to the length of the parameter, not the value. If you want to add the value, you’ll have to add the following:

    command.Parameters["@CustomerID"].Value = "5";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Microsoft's own PHP example for new Bing API doesn't work. I tried in many
Microsoft recently released tools and documentation for its new Phone 7 platform, which to
Microsoft provides a number of command line tools for working with asp.net applications. I
Microsoft like implementing their own versions of popular open-source frameworks and assemblies, for example:
Microsoft provides a method as part of WinHTTP which allows a user to determine
Microsoft introduced a new System.IO.MemoryMappedFiles namespace in .Net 4. Does anyone know if it
Microsoft Word has send as attachment functionality which creates a new message in Outlook
Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog(); dlg.FileName = Document; // Default file name dlg.DefaultExt =
Microsoft provides a way of mounting a read-only snapshot as a volume using their
Microsoft provides code in its article, How to serialize an object to XML by

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.