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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T14:28:37+00:00 2026-06-13T14:28:37+00:00

Whenever I execute my C# code everything goes well, no compiler errors, nothing. But

  • 0

Whenever I execute my C# code everything goes well, no compiler errors, nothing.
But when I go to look at my table in the server explorer, nothing was inserted.
Restarted Visual Studio, still nothing.

I went to debug and I looked at the cmd string before it executes ExecuteNonQuery() and the string still is @itmId,... etc. Not sure if that would effect it or not. Any help?

try
{
    Item workingItem = mItemList.Items[itemCombo.SelectedIndex - 1] as Item;
    SqlCeConnection sc = new SqlCeConnection(SalesTracker.Properties.Settings.Default.salesTrackerConnectionString);
    SqlCeCommand cmd = new SqlCeCommand("INSERT INTO Sales VALUES(@itmId, @itmNm,@fstNm, @date,@prft, @commision)", sc);
    cmd.Parameters.AddWithValue("@itmId", workingItem.ItemId);
    cmd.Parameters.AddWithValue("@itmNm", workingItem.ItemName);
    cmd.Parameters.AddWithValue("@fstNm", logedSalesmen.ID);
    cmd.Parameters.AddWithValue("@date", DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"));
    cmd.Parameters.AddWithValue("@prft", workingItem.Profit);
    cmd.Parameters.AddWithValue("@commision", workingItem.Commision);
    sc.Open();
    cmd.ExecuteNonQuery();
    sc.Close();
    MessageBox.Show("Save successfull");
    this.Close();
} 
catch (Exception exc)
{
    MessageBox.Show(exc.Message);
}

EDIT:So it is a matter of the temporary debug database being used, i used select count(0) to figure that out. But im not sure what i should use in my connection string to fix it.

  • 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-13T14:28:38+00:00Added an answer on June 13, 2026 at 2:28 pm

    The most common error here is actually a deployment thing – i.e. having 2 different database files in play. In particular, commonly the database file you are debugging (etc) against is often the one in “bin/debug” or similar, and gets overwritten every time you build. But the file people often look at to see the change is the one in their project tree.

    Make sure you are looking at the right file.

    The code looks fine; the fact that the parameters are still parameters is entirely expected and correct. If you want a simple way of validating the insert, then just check

    SELECT COUNT(1) FROM Sales 
    

    before and after the insert; I expect it will be incrementing.

    Also check that you are closing and disposing the connection cleanly (in case this is simply a buffered change that didn’t get written before the process terminated). Both sc and cmd are IDisposable, so you should use using really:

    using(SqlCeConnection sc = new SqlCeConnection(
        SalesTracker.Properties.Settings.Default.salesTrackerConnectionString))
    using(SqlCeCommand cmd = new SqlCeCommand(
        "INSERT INTO Sales VALUES(@itmId, @itmNm,@fstNm, @date,@prft, @commision)",
        sc))
    {
        cmd.Parameters.AddWithValue("@itmId", workingItem.ItemId);
        cmd.Parameters.AddWithValue("@itmNm", workingItem.ItemName);
        cmd.Parameters.AddWithValue("@fstNm", logedSalesmen.ID);
        cmd.Parameters.AddWithValue("@date",
            DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"));
        cmd.Parameters.AddWithValue("@prft", workingItem.Profit);
        cmd.Parameters.AddWithValue("@commision", workingItem.Commision);
        sc.Open();
        cmd.ExecuteNonQuery();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'd like to execute some code whenever a (any!) message box (as spawned by
The point of this timer is to execute some code whenever it's midnight. So
I want some personally developed JavaScript code to execute whenever I load a page
I am unable to register my BroadcastReceiver. Whenever I try to execute my code
Following code gets executed whenever I want to persist any entity. Things seems to
I want to execute a task with whenever rails gem at every reboot like
Can I create an event so I can execute some javascript whenever an element
Generally I keep directory specific settings in .bashrc and whenever I change directory execute
Configuring NHibernate to display executed SQL does what it's supposed to, but whenever a
I want to create a background worker for a WinForm that triggers code whenever

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.