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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T07:23:35+00:00 2026-05-14T07:23:35+00:00

UPDATED QUESTION: Ok, I am going to simplify my question since I don’t really

  • 0

UPDATED QUESTION:

Ok, I am going to simplify my question since I don’t really know how to answer your questions.

Say I create a new Windows Forms Application,
then Project->Add New Item->Local Database.

Then in Database Explorer I create a table (“testtable”) and give it an “ID” column and “VALUE” column.

Can you provide me with the steps to simply add a row to the database from the code?

OLD QUESTION:

I have been trying to do something
that I think would be really easy but
have never used C# before and am
having trouble with the details. I
simple want to use a sql database with
Visual C# Express 2008.

For testing purposes I have a datagrid
on my form that can reflect changes to
the db.

If i use this:

codesTableAdapter.Fill(dataSet1.codes);

The datagrid(dataset) will fill with
the info from the sql database.

If i then do something like this:

codesTableAdapter.InsertQuery(txtCode.Text,txtName.Text);
codesTableAdapter.Fill(dataSet1.codes);
codesTableAdapter.Update(dataSet1);
dataSet1.AcceptChanges();

The datagrid reflects the changes but
if close the program and go to the
database the changes are not there.
When I open the program again the
changes are not there.

I have a feeling this isn’t too clear
as my understanding here is very low
so please let me know what other info
is needed.

  • 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-14T07:23:35+00:00Added an answer on May 14, 2026 at 7:23 am

    Really hard to understand what is going on without seeing your code, but I will make some guesses:

    Say I create a new Windows Forms application then Project->Add New Item->Local Database

    This will create an empty SQL Server Compact Edition .SDF file in your project. You can edit this file from Visual Studio or SQL CE Query Analyzer.

    Then in Database Explorer I create a table (“testtable”) and give it an “ID” column and “VALUE” column.

    This will create an empty table in your .SDF file. Those are pretty bad names, but for test purpose we can use them.

    Can you provide me with the steps to simply add a row to the database from the code?

    System.Data.SqlServerCe provides methods to manage .SDF files. To add a row to your test table:

    using (SqlCeConnection myConnection = new SqlCeConnection(@"Data Source=Path\To\Your\SDF\file.sdf;"))
    using (SqlCeCommand myCmd = myConnection.CreateCommand())
    {
        myCmd.CommandType = CommandType.Text;
        myCmd.CommandText = "INSERT INTO testtable (ID, [VALUE]) VALUES (1, whatever)";
        myConnection.Open();
        myCmd.ExecuteNonQuery();
    }

    Be aware that Path\To\Your\SDF\file.sdf may not be what your think; Visual Studio by default copies project files to the Project Build Output Path (e.g. Path\to\your\project\bin\Debug\file.sdf). If you change the built file then rebuild your project, the original .SDF file gets recopied to your output path, wiping out any changes you have made to your project file. If that’s not what you want you will have to explain what you are trying to accomplish.

    For example, to make changes apply only to the built project file, change your data file “Copy to Output Directory” property in VS to “Copy if Newer”.

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

Sidebar

Related Questions

[Updated]: Answer inline below question I have an inspecting program and one objective is
Here is the updated question: the current query is doing something like: $sql1 =
Update: this question, including the title, was rephrased, see history for details I know
I have a question regarding an update function I created... CREATE OR REPLACE FUNCTION
This post started as a question on ServerFault ( https://serverfault.com/questions/131156/user-receiving-partial-downloads ) but I determined
I've updated the title and the text of my original question after gaining more
Updated: This is a re-write from my original question (or lack of), the main
EDIT Sorry for the confusion, here is my updated question. I am using FindBin
I don't have a specific question here but I'm more looking for some guidance
I'm sorry this question is going to be a bit vague because I'm not

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.