PC Review


Reply
Thread Tools Rate Thread

delete row from dataGridView problem

 
 
alexl
Guest
Posts: n/a
 
      23rd Jul 2007
Hi All,
I have been failing to delete a row from dataGridView.
I use typed dataset.
Here is my code, please advice what wrong is here?

private void MainForm_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the
'lodgersDataSet1.Table_Lodgers' table. You can move, or remove it, as
needed.


this.table_LodgersTableAdapter1.Fill(this.lodgersDataSet1.Table_Lodgers);



}


private void dataGridViewLodgers_RowsRemoved(object sender,
DataGridViewRowsRemovedEventArgs e)
{
string strConnString = @"Data Source=XP\SQLEXPRESS;Initial
Catalog=Lodgers;Integrated Security=True";
SqlConnection sqlConnection = new SqlConnection(strConnString);
SqlDataAdapter da = new SqlDataAdapter("SELECT * FROM
Table_1",sqlConnection);

MyDataSet myDataSet = new MyDataSet();
da.Fill(myDataSet, "Table_1");


// myDataSet is updated, row is deleted properly
//
DataRow dr = myDataSet.Table_1.Rows[e.RowIndex];
myDataSet.Tables["Table_1"].Rows.Remove(dr);


// Update returns 0 !!!
//
int ret = daLodgers.Update(dsLodgers2,
dsLodgers2.Tables[0].TableName);


myDataSet.Table_1.AcceptChanges();
myDataSet.AcceptChanges();



}


Thank you in advance
A.

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How do I add/delete row into/from a DataGridView Tony Microsoft C# .NET 6 29th Feb 2008 12:34 PM
How do I add/delete row into/from a DataGridView Tony Microsoft C# .NET 2 29th Feb 2008 10:46 AM
How do I display a confirmation dialog when the user tries to delete a row? When the user selects a row in the DataGridView and hits the delete key Amit Microsoft VB .NET 1 8th Aug 2006 05:07 PM
How do I display a confirmation dialog when the user tries to delete a row? When the user selects a row in the DataGridView and hits the delete key Amit Microsoft C# .NET 0 8th Aug 2006 05:02 PM
Refreshing datagridview contents after a failed delete in bound datagridview Bob Microsoft VB .NET 0 5th Jan 2006 06:34 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:06 PM.