I have been following this tutorial (http://msdn2.microsoft.com/en-us/library/ms233763(vs.80).aspx ) and so far everything has gone well. I am running Visual Studio 2005 and SQL Server 2005. I can run queries just fine. However, when I try to update (insert a new row), my Customers table in my SampleDatabaseDataSet will not commit any new changes.

I am using this documentation for adding rows: http://msdn2.microsoft.com/en-us/library/5ycd1034(VS.80).aspx

Here is my code:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace TestApp
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            SampleDatabaseDataSet.CustomersRow newCustomersRow = 
                sampleDatabaseDataSet.Customers.NewCustomersRow();

            newCustomersRow.CustomerID  = "AABCD";
            newCustomersRow.CompanyName = "AAA Works";

            sampleDatabaseDataSet.Customers.Rows.Add(newCustomersRow);

            // Why won't these changes commit?
            customersTableAdapter.Update(newCustomersRow);
            sampleDatabaseDataSet.Customers.AcceptChanges();
            customersBindingSource.EndEdit();

            this.customersTableAdapter.Fill(this.sampleDatabaseDataSet.Customers);
        }
    }
}

When this runs, the form displays that the row was added correctly. However, after the program is finished executing, the data is not written to the table. The changes don't really commit. Any ideas? Thanks.

I have the same problem can someone help

here is the test code:

deletetable is two columns only

ACRM.deletetableDataTable table = new ACRM.deletetableDataTable();

DataRowCollection rc;
DataRow newRow;
rc = table.Rows;
newRow = table.NewRow();
newRow[1] = "hello";
rc.Add(newRow);

the code runs but nothin gets written .. what are we doig wrong?


I have been following this tutorial (http://msdn2.microsoft.com/en-us/library/ms233763(vs.80).aspx ) and so far everything has gone well. I am running Visual Studio 2005 and SQL Server 2005. I can run queries just fine. However, when I try to update (insert a new row), my Customers table in my SampleDatabaseDataSet will not commit any new changes.

I am using this documentation for adding rows: http://msdn2.microsoft.com/en-us/library/5ycd1034(VS.80).aspx

Here is my code:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace TestApp
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            SampleDatabaseDataSet.CustomersRow newCustomersRow = 
                sampleDatabaseDataSet.Customers.NewCustomersRow();

            newCustomersRow.CustomerID  = "AABCD";
            newCustomersRow.CompanyName = "AAA Works";

            sampleDatabaseDataSet.Customers.Rows.Add(newCustomersRow);

            // Why won't these changes commit?
            customersTableAdapter.Update(newCustomersRow);
            sampleDatabaseDataSet.Customers.AcceptChanges();
            customersBindingSource.EndEdit();

            this.customersTableAdapter.Fill(this.sampleDatabaseDataSet.Customers);
        }
    }
}

When this runs, the form displays that the row was added correctly. However, after the program is finished executing, the data is not written to the table. The changes don't really commit. Any ideas? Thanks.

The problem i my code was that I did not update the table adapter revised code that works is shown
ACRMTableAdapters.deletetableTableAdapter deletetable_TA = new ACRMTableAdapters.deletetableTableAdapter();
ACRM ACRM1 = new ACRM();

ACRM.deletetableRow newRow = ACRM1.deletetable.NewdeletetableRow();
newRow.test1 = "ALFKI3";
ACRM1.deletetable.Rows.Add(newRow);
deletetable_TA.Update(newRow);

I hope this helps someone

I have been following this tutorial (http://msdn2.microsoft.com/en-us/library/ms233763(vs.80).aspx ) and so far everything has gone well. I am running Visual Studio 2005 and SQL Server 2005. I can run queries just fine. However, when I try to update (insert a new row), my Customers table in my SampleDatabaseDataSet will not commit any new changes.

I am using this documentation for adding rows: http://msdn2.microsoft.com/en-us/library/5ycd1034(VS.80).aspx

Here is my code:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace TestApp
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            SampleDatabaseDataSet.CustomersRow newCustomersRow = 
                sampleDatabaseDataSet.Customers.NewCustomersRow();

            newCustomersRow.CustomerID  = "AABCD";
            newCustomersRow.CompanyName = "AAA Works";

            sampleDatabaseDataSet.Customers.Rows.Add(newCustomersRow);

            // Why won't these changes commit?
            customersTableAdapter.Update(newCustomersRow);
            sampleDatabaseDataSet.Customers.AcceptChanges();
            customersBindingSource.EndEdit();

            this.customersTableAdapter.Fill(this.sampleDatabaseDataSet.Customers);
        }
    }
}

When this runs, the form displays that the row was added correctly. However, after the program is finished executing, the data is not written to the table. The changes don't really commit. Any ideas? Thanks.

I think you should use your update method to DataTable "Customers" insted of DataRow.

Easy!!!

var itemsSelected = dtSource[0][0];
dt.Rows.Add(AddRow(dt, itemsSelected));


 private DataRow AddRow(DataTable dt, DataRow dr)
        {
            DataRow newRow = dt.NewRow();
            newRow["Id"] = dr["ID"];
            newRow["Order"] = dr["Order"];          

            return newRow;
        }

http://www.ericklan.com/

I have the same problem can someone help

here is the test code:

deletetable is two columns only

 ACRM.deletetableDataTable table = new ACRM.deletetableDataTable();

        DataRowCollection rc;
        DataRow newRow;
        rc = table.Rows;
        newRow = table.NewRow();
        newRow[1] = "hello";
        rc.Add(newRow);

the code runs but nothin gets written .. what are we doig wrong?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.