?
Solved

Updating database using dataset

Posted on 2004-11-22
6
Medium Priority
?
216 Views
Last Modified: 2008-03-04
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 ?
0
Comment
Question by:Dhanraj_k
  • 4
  • 2
6 Comments
 
LVL 6

Expert Comment

by:Chester_M_Ragel
ID: 12643641
Can you post the update code?

Chester
0
 

Author Comment

by:Dhanraj_k
ID: 12651580
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
 
LVL 6

Expert Comment

by:Chester_M_Ragel
ID: 12652212
Remove objDS.AcceptChanges(); and try.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:Dhanraj_k
ID: 12662359
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
 
LVL 6

Accepted Solution

by:
Chester_M_Ragel earned 500 total points
ID: 12662403
Now you are getting some other error, Check this

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

Expert Comment

by:Chester_M_Ragel
ID: 12662415
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question