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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T18:19:36+00:00 2026-06-08T18:19:36+00:00

i want to insert data into sql server Compact edition the database table screenshot

  • 0

i want to insert data into sql server Compact edition the database table screenshot is Here >>>
i Want to add data in users the addition script is as follows

SqlCeConnection Con = new SqlCeConnection();
Con.ConnectionString = "Data Source = 'Database.sdf';" +
                       "Password='Password';";
Con.Open();
int Amount=Convert.ToInt32(AmBox.Text),
Code=Convert.ToInt32(MCode.Text),
Num=Convert.ToInt32(MNum.Text);
string Name=Convert.ToString(NBox.Text),
FName=Convert.ToString(SOBox.Text),
Address=Convert.ToString(AdBox.Text);

SqlCeCommand Query =new SqlCeCommand("INSERT INTO Users VALUES " + 
                        "(++ID,Name,FName,Address,Code,Num,Amount)",Con);
Query.ExecuteReader();

When it runs it generates an error SAYING “The column name is not valid [Node Name (if any) =,Column name=ID ]

I don’t figure out the problem kindly tell me thanks!

  • 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-08T18:19:37+00:00Added an answer on June 8, 2026 at 6:19 pm

    You should change your code to something like this

    using(SqlCeConnection Con = new SqlCeConnection("Data Source = 'Database.sdf';" + 
                                                    "Password='Password';")
    { 
        Con.Open(); 
        SqlCeCommand Query = new SqlCeCommand("INSERT INTO Users " + 
                                 "(Name,FName,Address,MCode,MNum,Amount) " +
                                 "VALUES (@Name,@FName,@Address,@Code,@Num,@Amount)",Con); 
    
        Query.Parameters.AddWithValue("@Name", NBox.Text);
        Query.Parameters.AddWithValue("@FName", SOBox.Text)); 
        Query.Parameters.AddWithValue("@Address",AdBox.Text)); 
        Query.Parameters.AddWithValue("@Code", Convert.ToInt32(MCode.Text));
        Query.Parameters.AddWithValue("@Num", Convert.ToInt32(MNum.Text));
        Query.Parameters.AddWithValue("@Amount" , Convert.ToInt32(AmBox.Text));
        Query.ExecuteNonQuery(); 
    }
    
    • The using statement guarantees the correct disposing of the
      connection
    • The Parameter collection avoid Sql Injection Attacks and quoting
      problems
    • Use of ExecuteNonQuery because this is an insert query.
    • Removed the ++ID, it is not a valid value to pass to the database

    If the ID field is an Identity column, then you don’t pass any value from code, but let the database calculate the next value.
    Also, I’m not sure you really need the single quote in your connection string around the data source and password keys.

    EDIT —
    Sometimes the .SDF database could be located in a different folder.
    (Modern operating systems prevent writing in the application folder).
    In this case is necessary to set the path to the SDF file in the connection string.
    For example, the SDF could be located in a subfolder of the C:\ProgramData directory.

    string conString = "Data Source=" + 
            Path.Combine(
                   Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData),
                   "MyAppData\\database.sdf") + ";Password=yourPassword;";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to insert this XML data into SQL Server 2008 <rewriteMap name=OldStaticUrl> <add
I want to insert data into SQL Server database when I click Insert button
I want to insert this piece of data into SQL Compact 3.5 using the
I want to import data from Excel worksheet into SQL Server database (2008). I
I want to insert data into a table where I don't know the next
I want to insert data into the postgresql database of OpenERP, I am able
I want to insert a record into a MySQL database table from a formulaire.
I have a user table. I want to insert data into my user table.
i retrieve data from upc database and then want to insert the data into
I have a sql server database that I want to bring into a datagrid.

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.