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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T07:45:58+00:00 2026-06-03T07:45:58+00:00

In my database, I have a table with a primary key identity column, and

  • 0

In my database, I have a table with a primary key identity column, and 3 other columns as follows.

I want to manually create a DataTable and save it to my SQL Server CE database. Can anyone help me tweak my code please?

DataTable table1 = new DataTable("MyTable1");
table1.Columns.Add("LastName");
table1.Columns.Add("FirstName");
table1.Columns.Add("SortColumn");
table1.Rows.Add("Doe", "John", 1);
table1.Rows.Add("Doe", "Mary", 2);

DataSet ds = new DataSet("notCritical1");
ds.Tables.Add(table1);

using (SqlCeConnection con = new SqlCeConnection(TestClickOnceApp.classes.ClassDatabase.m_connectionString))
{
    con.Open();
    SqlCeDataAdapter da = new SqlCeDataAdapter("Select * from MyTable1", con);
    da.Fill(ds, "MyTable1");
    da.Update(ds, "MyTable1");
}
  • 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-03T07:46:00+00:00Added an answer on June 3, 2026 at 7:46 am

    I haven’t SqlCompact to test, but I presume you could write code like this

    using (SqlCeConnection con = new SqlCeConnection(connectionString))   
    {   
        con.Open();   
        SqlCeCommand cmd = new SqlCeCommand("Select * from MyTable1 Where 1=0", con);
        SqlCeDataAdapter da = new SqlCeDataAdapter();
        da.SelectCommand = cmd;
        SqlCeCommandBuilder cb = new SqlCeCommandBuilder(da);
        da.Update(table1);
    }
    

    no need to use a dataset

    More details on the base class method DbDataAdapter.Update(DataTable t) can be found here

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

Sidebar

Related Questions

I have a database table with the primary column defined as: ID bigint identity
I have a simple country table using a identity column for the primary key.
In my database I have table AnimalDetails containing animalNumber(primary key),name,breed dateofbirth and an image
I have a database table A which stores records, A has a primary key
I'm creating a database table and I don't have a logical primary key assigned
I need to change the primary key of a table to an identity column,
i have a char(10) column in a table in a SQL-Server 2005 database: CREATE
My database has a parent table with an auto-incrementing primary key identity 'ID', and
I have two database tables with the following structure: actions: action_id int(11) primary key
I have created a database where I use uniqueidentifier as the primary key. I'm

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.