Friday, June 08, 2007

Bug buster blog!!

I am going to transfer my blog to a so call Bug buster blog!
Frustrated to see lots of bug in my program, popping out every where in every minutes or even seconds...
The first stupid bug is
"Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints."

Well, basically this error message tell you NOTHING...one of the useless error message by Visual Studio 2005....
Okie, after I google this error message and found this useful LINK
So by putting this below function into the try and catch function:
-------------------------------------------------------------------------------------------------------------------------------------
[C#] 
private void PrintAllErrs(DataSet myDataSet){
DataRow[] rowsInError;

foreach(DataTable myTable in myDataSet.Tables){
// Test if the table has errors. If not, skip it.
if(myTable.HasErrors){
// Get an array of all rows with errors.
rowsInError = myTable.GetErrors();
// Print the error of each column in each row.
for(int i = 0; i <>
foreach(DataColumn myCol in myTable.Columns){
Console.WriteLine(myCol.ColumnName + " " +
rowsInError[i].GetColumnError(myCol));
}
// Clear the row errors
rowsInError[i].ClearErrors();
}
}
}
}

-------------------------------------------------------------------------------------------------------------------------------------
It tell you what's went wrong, rather then give you an useless error message



No comments: