Hi,
In my .Net 1.1 C# winodows form project,
I use the following code trying to update data via a DataGrid.
private void UpdateDataSet(DataSet myDataSet){
if(!myDataSet.HasChanges(DataRowState.Modified)) return;
DataSet xDataSet;
xDataSet = myDataSet.GetChanges(DataRowState.Modified);
if(xDataSet.HasErrors){ }
mySqlDataAdapter.Update(xDataSet);
}
private void btnSave_Click(object sender, System.EventArgs e)
{
this.UpdateDataSet(myGridDS);
}
However, it comes out with an error message saying something wrong with the
modified DataRow and UpdateCommand.
Would someone tell me how to fix it?
Thanks for help.
Jason 4 7018
could you be more specific about exception you get.
why do you exctract changes from datatset? DataAdapater does this for
you as it calls respectively UpdateCommand, Insertcommand and
Deletecommand for each changed, inserted or deleted row.
just call mySqlDataAdapter.Update(myDataSet);
hope this helps
Galin Iliev[MCSD.NET] www.galcho.com
Jason Huang wrote: Hi,
In my .Net 1.1 C# winodows form project, I use the following code trying to update data via a DataGrid.
private void UpdateDataSet(DataSet myDataSet){ if(!myDataSet.HasChanges(DataRowState.Modified)) return; DataSet xDataSet; xDataSet = myDataSet.GetChanges(DataRowState.Modified); if(xDataSet.HasErrors){ } mySqlDataAdapter.Update(xDataSet); }
private void btnSave_Click(object sender, System.EventArgs e) { this.UpdateDataSet(myGridDS); }
However, it comes out with an error message saying something wrong with the modified DataRow and UpdateCommand. Would someone tell me how to fix it? Thanks for help.
Jason
Thanks!
I made up the UpdateCommand, InsertCommand, DeleteCommand for
MySqlDataAdapter.
And it worked fine with the Insert and Update.
When I delete a row form the DataGrid, that row will be deleted but it pops
out a message with System.Data.RowNotInTableException.
How do I solve this problem.
Thanks for help.
Jason
"Galcho[MCSD.NET]" <ga****@gmail.com>
???????:11*********************@y41g2000cwy.google groups.com... could you be more specific about exception you get.
why do you exctract changes from datatset? DataAdapater does this for you as it calls respectively UpdateCommand, Insertcommand and Deletecommand for each changed, inserted or deleted row.
just call mySqlDataAdapter.Update(myDataSet);
hope this helps Galin Iliev[MCSD.NET] www.galcho.com
Jason Huang wrote: Hi,
In my .Net 1.1 C# winodows form project, I use the following code trying to update data via a DataGrid.
private void UpdateDataSet(DataSet myDataSet){ if(!myDataSet.HasChanges(DataRowState.Modified)) return; DataSet xDataSet; xDataSet = myDataSet.GetChanges(DataRowState.Modified); if(xDataSet.HasErrors){ } mySqlDataAdapter.Update(xDataSet); }
private void btnSave_Click(object sender, System.EventArgs e) { this.UpdateDataSet(myGridDS); }
However, it comes out with an error message saying something wrong with the modified DataRow and UpdateCommand. Would someone tell me how to fix it? Thanks for help.
Jason
I have the
MyTable = myGridDS.Tables[0];
MyTable.AcceptChanges();
And now the Delete is working fine.
"Jason Huang" <Ja************@hotmail.com> ¼¶¼g©ó¶l¥ó·s»D:ep**************@TK2MSFTNGP05.phx.g bl... Thanks! I made up the UpdateCommand, InsertCommand, DeleteCommand for MySqlDataAdapter. And it worked fine with the Insert and Update. When I delete a row form the DataGrid, that row will be deleted but it pops out a message with System.Data.RowNotInTableException. How do I solve this problem. Thanks for help.
Jason
"Galcho[MCSD.NET]" <ga****@gmail.com> ???????:11*********************@y41g2000cwy.google groups.com... could you be more specific about exception you get.
why do you exctract changes from datatset? DataAdapater does this for you as it calls respectively UpdateCommand, Insertcommand and Deletecommand for each changed, inserted or deleted row.
just call mySqlDataAdapter.Update(myDataSet);
hope this helps Galin Iliev[MCSD.NET] www.galcho.com
Jason Huang wrote: Hi,
In my .Net 1.1 C# winodows form project, I use the following code trying to update data via a DataGrid.
private void UpdateDataSet(DataSet myDataSet){ if(!myDataSet.HasChanges(DataRowState.Modified)) return; DataSet xDataSet; xDataSet = myDataSet.GetChanges(DataRowState.Modified); if(xDataSet.HasErrors){ } mySqlDataAdapter.Update(xDataSet); }
private void btnSave_Click(object sender, System.EventArgs e) { this.UpdateDataSet(myGridDS); }
However, it comes out with an error message saying something wrong with the modified DataRow and UpdateCommand. Would someone tell me how to fix it? Thanks for help.
Jason
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Chris Plowman |
last post by:
Hi all,
I was wondering if anyone can help me with a really annoying problem I have
been having. I made a derived datagrid class that will select the row when
a user clicks anywhere on a cell...
|
by: Pam Ammond |
last post by:
After clicking btnDeleteSize_Click in frmSize, I move to frmSizeDelete, allow
deleting a Size using a datagrid, and then return to frmSize and want to
update the datagrid in frmSize to reflect the...
|
by: Glenn Owens |
last post by:
I have a DataGrid web control which I've dynamically populated with
template columns to be used for bulk-editting. Generally, all of the
columns are textbox and/or dropdownlist child controls.
...
|
by: Rick |
last post by:
Hello all, I hope all is well with you.
I am having a seriously difficult time with this problem. Allow me to
set
up the problem.
I have a System.Web.UI.Page with the following controls...
|
by: Steve |
last post by:
I have a datagrid that is created at run time
DataGrid dgG = new DataGrid();
BoundColumn bcB;
dgG.CellPadding = 5;
dgG.CellSpacing = 0;
dgG.GridLines = GridLines.Both;
dgG.CssClass =...
|
by: tshad |
last post by:
I am having trouble with links in my DataGrid.
I have Links all over my page set to smaller and they are consistant all
over the page in both Mozilla and IE, except for the DataGrid.
Here is a...
|
by: junglist |
last post by:
Hi guys,
I've been trying to implement an editable datagrid and i have been
succesful up to the point where i can update my datagrid row by row.
However what used to happen was that once i updated...
|
by: Tina |
last post by:
the Edit, Update, Cancel, and Delete buttons in my datagrid are causing
validation elsewhere on the page. I want to specify that these buttons
should not cause validation but they have no design...
|
by: A_PK |
last post by:
I have problem databinding the DataGrid with DataView/DataSet after the
filter...
I create the following proceudre in order for user to filter as many as they
want, but the following code is only...
|
by: rn5a |
last post by:
A Form has a DataGrid which displays records from a SQL Server 2005 DB
table. Users can modify the records using this DataGrid for which I am
using EditCommandColumn in the DataGrid. This is the...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |