Updating database using dataset

I am populating values to a datagrid using dataset. After modifying the grid, I am updating the database using command builder, but it is not working. can anybody plz help me ?
Dhanraj_kAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Chester_M_RagelCommented:
Can you post the update code?

Chester
0
Dhanraj_kAuthor Commented:
hi Chester,
here is the code:

private OdbcCommandBuilder objBuilder=new OdbcCommandBuilder();
private OdbcDataAdapter objDA=new OdbcDataAdapter();
DataTable objTable=new DataTable();
DataSet objDS=new DataSet();

// clsDbConnection is the connection class

string strSL="select * employee";
objDA=new OdbcDataAdapter(strSL,clsDbConnection.objConn);
objDA.Fill(objDS,"employee");
dataGrid1.DataSource=objDS.Tables["employee"].DefaultView;
dataGrid1.SetDataBinding(objDS,"employee");
objTable=objDS.Tables["employee"];


      private void button1_Click(object sender, System.EventArgs e)
      {
            objDS.AcceptChanges();
            objBuilder=new OdbcCommandBuilder(objDA);
            objDA.UpdateCommand=objBuilder.GetUpdateCommand();
            objDA.Update(objDS,"employee");
            MessageBox.Show("Table updated");
      }
0
Chester_M_RagelCommented:
Remove objDS.AcceptChanges(); and try.
0
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

Dhanraj_kAuthor Commented:
Sorry Chester,
Still it is not working. I am getting the error "System.Data.Odbc.OdbcException: ERROR [07006] [MySQL][ODBC 3.51 Driver][mysqld-4.1.3-beta-nt-max]Restricted data type attribute violation(SQL_C_NUMERIC)
   at System.Data.Common.DbDataAdapter.Update(DataRow[] dataRows, DataTableMapping tableMapping)
   at System.Data.Common.DbDataAdapter.Update(DataSet dataSet, String srcTable)
   at button1_Click(Object sender, EventArgs e)"
0
Chester_M_RagelCommented:
Now you are getting some other error, Check this

http://www.x-code.com/raccess/manual/troubleshooting.htm
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Chester_M_RagelCommented:
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.