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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T12:54:40+00:00 2026-06-16T12:54:40+00:00

I am trying to delete an old row from a sql-server-ce database (based on

  • 0

I am trying to delete an old row from a sql-server-ce database (based on the primary key value), whenever that primary key value is updated.

The goal is to (once supplied with the new id) add a new entry with an insert statement and then delete the old entry. It might be important to know that the data type for the primary key (City Tag Number) within the database itself is int, and the C# variable originalCTag was declared var, but assigned “” (empty string) upon its declaration, and then assigned the string representation of the desired target primary key value.

While this should be a simple task, here’s the question:

Why is the sql action query not working? Using C# in WebMatrix, here is what I have tried:

db.Execute("DELETE FROM Vaccinations WHERE [City Tag Number] = " + originalCTag);

^This states that there was an error parsing the query at the index of the equals sign.

db.Execute("DELETE FROM Vaccinations WHERE [City Tag Number] = @0", originalCTag);

^This states that the input string was not in the correct format.

db.Execute("DELETE FROM Vaccinations WHERE [City Tag Number] = @0", int.Parse(originalCTag));

^This states that the input string was not in the correct format.

db.Execute("DELETE FROM Vaccinations WHERE [City Tag Number] = @0", originalCTag.ToString());

^This (once again) states that the input string was not in the correct format (can we not parameterize queries with a DELETE statement)?

So… lastly, I tried:

db.Execute("DELETE FROM Vaccinations WHERE [City Tag Number] = '" + originalCTag + "'");

^This doesn’t produce any errors, but also does not do what it’s supposed to (e.g., delete the row).

At this point, I’m kind of at a loss. I would expect at least one of these statements to perform the desired function, if not a few of them.

Clearly I am missing something (and I wouldn’t be surprised if that something was obvious) here. If any of these statements ‘should work’ then maybe there is something else wrong with my code before the db.Execute statement.

——————-UPDATE—————–
In case you want to see the db declaration statement:

var db = Database.Open("Vaccinations");

Yes, Vaccinations is the name of the database and the (only) table within that database.

  • 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-16T12:54:41+00:00Added an answer on June 16, 2026 at 12:54 pm

    The combined error messages say that the value held by originalCTag is not a number. It is most likely still an empty string since that is what you say you first assigned it to. You should check that the code that you use to assign it a valid value does what you think it does.

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

Sidebar

Related Questions

I am trying to delete an old user from our perforce installation. A previous
I need to delete old and unmaintained branches from our remote repository. I'm trying
I'm trying to delete old SVN files from directory tree. shutil.rmtree and os.unlink raise
I'm trying to script bacula to delete old files that are not used any
I'm trying to delete a user's schema from a database and I'm getting the
I'm trying to write a small batch script that will delete files old files
Hi im strugeling with SQLite in android. Im trying to delete old posts from
Am trying to delete some old records out of a small employee database (with
I am trying to delete MySQL table rows from a Web page using Perl.
I'm trying to delete a specific line by id from a file in C++

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.