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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T03:11:39+00:00 2026-05-24T03:11:39+00:00

This code reads and updates the form fine when I run the program, but

  • 0

This code reads and updates the form fine when I run the program, but it does not update when I edit the values in the datagridview and click update.
I am following a video tutorial series and this code does work in the video to update the table.

Question: Why does it not update when I edit the values in the datagridview?

using System.Data.SqlServerCe;

namespace WindowsFormsApplication2
{
    public partial class Form1 : Form
    {
        private SqlCeConnection conn;       // Our Connection
        private SqlCeDataAdapter da;        // Data Adapter
        private DataSet ds;                 // Dataset
        private string sTable = "authors";  // Table Name

        public Form1()
        {
            InitializeComponent();
            InitData(); // Get the Data
            dataGridView1.DataSource = ds;
            dataGridView1.DataMember = sTable;              
        }

        public void InitData()
        {
            try
            {
                // Instantiate the Connection
                conn = new SqlCeConnection("Data Source=|DataDirectory|\\Database1.sdf");

                // Instantiate a new DataSet
                ds = new DataSet();

                // init SQLDataAdapter with select command and connection
                da = new SqlCeDataAdapter("SELECT id, name, email FROM " + sTable, conn);

                // Automatically generates insert, update and delete commands
                SqlCeCommandBuilder cmdBldr = new SqlCeCommandBuilder(da);

                // Fill in the dataset view
                da.Fill(ds, sTable);

            }
            catch (Exception excep)
            {
                MessageBox.Show("Exception: " + excep.Message);
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                da.Update(ds, sTable);
            }
            catch (Exception excep)
            {
                MessageBox.Show(excep.Message);
            }
        }
    }
}

The program compiles, but the update command is not working to update the database on click of button1.

  • 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-24T03:11:39+00:00Added an answer on May 24, 2026 at 3:11 am

    This may seem silly but have you checked that the user name you are using to connect has write permissions and not just read-only on the database?

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

Sidebar

Related Questions

Jquery UI Dialog modal-form doesn't shows up inside table, but works fine outside. This
this is part of my code which reads an http response. It's supposed to
On document ready I run this code: jQuery(document).ready(function(){ jQuery('#button').click(function() { jQuery('#contact_form').load(/Users/mge/Downloads/jquery-ajax-1/readme.txt); return false; });
I am using this code to sum values from multiple radio buttons : $(document).ready(function(){
I'm using this code to submit a form to a php script: var valid
I have this code below: <?php function wp_copickpage() { color_option_update(); ?> <form method=POST action=>
This code works when it is included in the HTML file, but I'd rather
ConcurrentHashMap in Java offers reads to proceed concurrently with updates. The trade-off in this
take a look at this code: $(document).ready(function() { document.getElementById(sliderId).onmousedown = sliderMouseDown; }); function sliderMouseDown()
I have this code in jQuery.. $(document).ready(function(){ var fieldCounter = 0; ... I have

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.