Quantcast
Viewing all articles
Browse latest Browse all 20

Re: dynamic Filter ( Using multiple drop down list)

catch (Exception exception)
{    // Wim, it catches the error here

No, it does not; It catches AN error there.

protected bool GetData(DateTime start, DateTime end, string campaign)
{
...
...
    /**/
    DataSet dataSet = null;
    /**/
...
...
    try
    {
// what happens if an exception occurs here? ... ... /**/ dataSet = new DataSet(); /**/ ... ... } catch (Exception exception) { // ... ... } finally { /**/ dataSet.Dispose(); /**/ ... ... } return flag; }

Above is a stripped version. Think if what happens if an exception is thrown before you create a new instance of DataSet. dataSet will be null and in the finally you try to dispose.

To prevent the crash, change DataSet dataSet = null; toDataSet dataSet = new DataSet(); and remove the line in the try block that instantiated a new instance of DataSet. You still have to analyze the real error in the catch block to see what exactly goes wrong and prevent it from occuring ;-)

PS
Please use the little icon with the {} in the toolbar of the editor window of this forum to keep the formatting of code; it's a lot easier to read.


Viewing all articles
Browse latest Browse all 20

Trending Articles