datagrid update database exception.

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for MySQL
Post Reply
AceEmbler
Posts: 26
Joined: Fri 04 Aug 2006 09:45

datagrid update database exception.

Post by AceEmbler » Tue 08 Aug 2006 09:29

I have added mysqlCommand in design mode to mysqlDataAdapter.
(SELECT * FROM table)

I have added mysqlCommandBuilder in design mode to mysqlDataAdapter. Do I have to add commands for updating to mysqlCommandBuilder ??

How can i use mySqlDataAdapter1.Fill(dataSetDB); without my own command ??

I am obtaining data from data base and put it into data grid like this.
(works fine)

Code: Select all

DataSet dataSetDB=new DataSet();
mySqlConnection1.Open();
mySqlDataAdapter1.Fill(dataSetDB);
dataGrid1.DataSource = dataSetDB.Tables[0];
mySqlConnection1.Close();
After changing some records im trying to update database like this

Code: Select all

            mySqlConnection1.Open();
            dt = (DataTable)dataGrid1.DataSource;
            mySqlDataAdapter1.Update(dt); //<--this line generates InvalidOperationException
            mySqlConnection1.Close();

Serious

Post by Serious » Tue 08 Aug 2006 09:46

If you want INSERT/UPDATE/DELETE commands to be generated automatically, you have to create MySqlCommandBuilder object and assign MySqlCommandBuilder.DataAdapter property.

For more information and code samples please refer to MySQLDirect .NET documentation.

AceEmbler
Posts: 26
Joined: Fri 04 Aug 2006 09:45

Post by AceEmbler » Tue 08 Aug 2006 09:57

I have already done that.


I just messed the text.
I have added mysqlCommandBuilder in design mode to mysqlDataAdapter

Serious

Post by Serious » Tue 08 Aug 2006 10:16

Please provide an exception text.

AceEmbler
Posts: 26
Joined: Fri 04 Aug 2006 09:45

Post by AceEmbler » Tue 08 Aug 2006 10:22

InvalidOperationException

As I already mentioned in my code.
And im writing/testing on PDA (windows mobile 5.0).

AceEmbler
Posts: 26
Joined: Fri 04 Aug 2006 09:45

Post by AceEmbler » Tue 08 Aug 2006 11:04

I just discovered that i can add new rows to my database but the problem is when i have to modify existing rows.

Serious

Post by Serious » Tue 08 Aug 2006 12:53

Provide an exception text and call stack.

AceEmbler
Posts: 26
Joined: Fri 04 Aug 2006 09:45

Post by AceEmbler » Wed 09 Aug 2006 07:54

Exception:
InvalidOperationException
Message text is written in my language so it's probably something default.
My Translation:
"Message about error cannot be displayed,......"

StackTrace:

Code: Select all

w System.Data.Common.DbCommandBuilder.BuildWhereClause()
w System.Data.Common.DbCommandBuilder.BuildUpdateCommand()
w System.Data.Common.DbCommandBuilder.RowUpdatingHandlerBuilder()
w System.Data.Common.DbCommandBuilder.RowUpdatingHandler()
w CoreLab.MySql.MySqlCommandBuilder.e()
w CoreLab.MySql.MySqlDataAdapter.OnRowUpdating()
w System.Data.Common.DbDataAdapter.Update()
w System.Data.Common.DbDataAdapter.UpdateFromDataTable()
w System.Data.Common.DbDataAdapter.Update()
w DeviceApplication2.Form1.DO_IT_Click()
w System.Windows.Forms.Control.OnClick()
w System.Windows.Forms.Button.OnClick()
w System.Windows.Forms.ButtonBase.WnProc()
w System.Windows.Forms.Control._InternalWnProc()
w Microsoft.AGL.Forms.EVL.EnterMainLoop()
w System.Windows.Forms.Application.Run()
w DeviceApplication2.Program.Main()

Serious

Post by Serious » Wed 09 Aug 2006 11:38

This discussion is continued in another topic.

Post Reply