Click here to Skip to main content
15,916,945 members
Home / Discussions / C#
   

C#

 
QuestionError in Mail sending Pin
Exelioindia9-Oct-07 2:00
Exelioindia9-Oct-07 2:00 
AnswerRe: Error in Mail sending Pin
JSSUML9-Oct-07 2:04
JSSUML9-Oct-07 2:04 
QuestionExcel to DataTable Pin
vijay_chaudhary9-Oct-07 1:59
vijay_chaudhary9-Oct-07 1:59 
AnswerRe: Excel to DataTable Pin
Paul Conrad12-Oct-07 13:36
professionalPaul Conrad12-Oct-07 13:36 
QuestionA situation where you have to use goto Pin
Bummer89-Oct-07 1:57
Bummer89-Oct-07 1:57 
AnswerRe: A situation where you have to use goto Pin
Andrei Ungureanu9-Oct-07 2:07
Andrei Ungureanu9-Oct-07 2:07 
GeneralRe: A situation where you have to use goto Pin
Colin Angus Mackay9-Oct-07 2:10
Colin Angus Mackay9-Oct-07 2:10 
AnswerRe: A situation where you have to use goto Pin
Colin Angus Mackay9-Oct-07 2:09
Colin Angus Mackay9-Oct-07 2:09 
Bummer8 wrote:
_labelRowDeleted:
foreach (DataRow myRow in dataset.Tables["grant"].Rows)
{
if (myRow["principal_Id"].ToString() == nPrincipal_Id.ToString())
{
myRow.Delete();
goto _labelRowDeleted;
}
}



do
{
    bool restart = false;
    foreach (DataRow myRow in dataset.Tables["grant"].Rows)
    {
        if (myRow["principal_Id"].ToString() == nPrincipal_Id.ToString())
        {
            myRow.Delete();
            restart = true;
            break;
        }
    }
}
while (restart == true);


Although I'm not entirely sure why you are starting the loop over again when you are deleting a row.

I would imagine the following would have the same effect and be more efficient (by traversing the rows backwards)
DataRows rows = dataset.Tables["grant"].Rows;
for(int i=rows.Length-1; i>=0; i--)
{
    DataRow myRow = rows[i];
    if (myRow["principal_Id"].ToString() == nPrincipal_Id.ToString())
    {
        myRow.Delete();
    }
}




Upcoming FREE developer events:
* Glasgow: db4o: An Embeddable Database Engine for Object-Oriented Environments, Mock Objects, SQL Server CLR Integration, Reporting Services ...

My website

AnswerRe: A situation where you have to use goto Pin
JSSUML9-Oct-07 2:09
JSSUML9-Oct-07 2:09 
AnswerRe: A situation where you have to use goto Pin
Guffa9-Oct-07 2:26
Guffa9-Oct-07 2:26 
AnswerRe: A situation where you have to use goto Pin
Bummer89-Oct-07 4:13
Bummer89-Oct-07 4:13 
GeneralRe: A situation where you have to use goto Pin
Dan Neely9-Oct-07 4:52
Dan Neely9-Oct-07 4:52 
GeneralRe: A situation where you have to use goto [modified] Pin
Dave Kreskowiak9-Oct-07 5:14
mveDave Kreskowiak9-Oct-07 5:14 
QuestionCross-thread operation not valid on toolstripstatuslabel Pin
Hampus@foi9-Oct-07 0:58
Hampus@foi9-Oct-07 0:58 
AnswerRe: Cross-thread operation not valid on toolstripstatuslabel Pin
Muammar©9-Oct-07 1:05
Muammar©9-Oct-07 1:05 
Questioncustom desktop in C# Pin
amruta kadam9-Oct-07 0:09
amruta kadam9-Oct-07 0:09 
AnswerRe: custom desktop in C# Pin
Muammar©9-Oct-07 0:47
Muammar©9-Oct-07 0:47 
AnswerRe: custom desktop in C# Pin
Mustafa Ismail Mustafa9-Oct-07 0:49
Mustafa Ismail Mustafa9-Oct-07 0:49 
QuestionHow to disable the Automatic ToolTip Of TreeView Pin
Venki568-Oct-07 23:51
Venki568-Oct-07 23:51 
AnswerRe: How to disable the Automatic ToolTip Of TreeView Pin
Luc Pattyn9-Oct-07 0:30
sitebuilderLuc Pattyn9-Oct-07 0:30 
QuestionClass libary streamwriter Pin
Scalee8-Oct-07 23:43
Scalee8-Oct-07 23:43 
AnswerRe: Class libary streamwriter Pin
Luc Pattyn9-Oct-07 0:33
sitebuilderLuc Pattyn9-Oct-07 0:33 
GeneralRe: Class libary streamwriter Pin
Scalee9-Oct-07 0:48
Scalee9-Oct-07 0:48 
QuestionQuestion about switch statement Pin
Andrei Ungureanu8-Oct-07 23:27
Andrei Ungureanu8-Oct-07 23:27 
AnswerRe: Question about switch statement Pin
J4amieC8-Oct-07 23:41
J4amieC8-Oct-07 23:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.