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

  • Home
  • SEARCH
  • 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 585479
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T15:00:26+00:00 2026-05-13T15:00:26+00:00

I got some data inputed by the user that should be added to a

  • 0

I got some data inputed by the user that should be added to a Database File (.sdf). I’ve choose Sql Server CE because this application is quite small, and i didn’t saw need to work with a service based database.

Well any way.

Here goes the code:

public class SqlActions
{
    string conStr = String.Format("Data Source = " + new System.IO.FileInfo(System.Reflection.Assembly.GetExecutingAssembly().Location).DirectoryName + "\\basedados.sdf");

    public SqlCeConnection SQLCEConnect()
    {
        SqlCeConnection Connection = new SqlCeConnection(conStr);
        Connection.Open();
        return Connection;
    }

    public Boolean AdicionarAuditorio(string Nome, int Capacidade)
    {
        string Query = "INSERT INTO auditorios (nome, capacidade) VALUES (@Nome, @Capacidade)";
        using (var SQLCmd = new SqlCeCommand(Query, SQLCEConnect()))
        {
            SQLCmd.Parameters.AddWithValue("@Nome", Nome);
            SQLCmd.Parameters.AddWithValue("@Capacidade", Capacidade);
            if (SQLCmd.ExecuteNonQuery() == 1)
            {
                return true;
            } else {
                return false;
            }

        }
    }
}

I use the AdicionarAuditorio(string Nome, int Capacidade) function to Insert the data. running ExecuteNonQuery() which is supposed to return the number of affected rows after he as run the query.
So it should return 1 if the query as successful, right?

In the end he returns 1, but if I browser the table data, the data that the query should add isn’t there.

So whats wrong here?

NOTE. If your thinking that the
problem is the connection: I can’t see
why is the problem once i got some
Select statements that use that
connection function SQLCEConnect()
and they all work pretty well.

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-05-13T15:00:26+00:00Added an answer on May 13, 2026 at 3:00 pm

    Are you sure you are looking at the right file? When you build your app in VS, it copies the SDF file as content to the target folder, so the database in your project will not reflect any updates. Your code is picking up the the file location there.

    This is btw not a good practice, because once deployed, the program folders are not writable to your app (could this be the problem – did you already deploy?). Instead, the database file should reside in your appdata folder.

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

Sidebar

Ask A Question

Stats

  • Questions 297k
  • Answers 297k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer My VB sucks, but I think it would be: Dim… May 13, 2026 at 7:13 pm
  • Editorial Team
    Editorial Team added an answer It depends what you mean by "manage instances". If you… May 13, 2026 at 7:13 pm
  • Editorial Team
    Editorial Team added an answer Catching the pre_save signal will allow you to inject a… May 13, 2026 at 7:13 pm

Related Questions

I got some files , which has header, {AD08E961-F492-11d1-B0EA-00AA00683350}2.00:en_US:45015:021 Can you please help me
Alright, I have some data that I need to assign an int type identifier
For an unknown reason, I have 1 page that I can't access by ID
I've got some data files that are stored compressed on our company's server with
I've got some data manipulation code which spits out csv at the end. I

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.