Why DataSet always returns null?
-
Since some experienced programmers like Dan Neely didn't get humor feeling from my post, I do need to add the following words at the bottom of my post: (Hint: the programmer set ds = null in section finally before returning his ds)
che3358 wrote:
(Hint: the programmer set ds = null in section finally before returning his ds)
That was one of the first things I noticed :-\
"The clue train passed his station without stopping." - John Simmons / outlaw programmer "Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
-
A programmer told me he just learned try...catch, and found it's very powerful. Later, he found one of his methods always return null after he implemented try...catch. Here is his code:
private DataSet GetData()
{
DataSet ds = null;
try
{
ds = new DataSet();
//Get data
//And assign ds = someData
}
catch
{
//Handle some error
}
finally
{
ds = null;
}return ds;
}
-
You are as funny as the programmer. Did you think I am looking for help from you? Read my post again carefully please!
hmmmm .... this how he read the post ... try { CheckIfPostIsInCorrectForum(); } catch { WriteWrongPostMessage(); } finaly { WriteWrongPostMessageExt(); } :) :) :) :) ;P *hehe*
-
A programmer told me he just learned try...catch, and found it's very powerful. Later, he found one of his methods always return null after he implemented try...catch. Here is his code:
private DataSet GetData()
{
DataSet ds = null;
try
{
ds = new DataSet();
//Get data
//And assign ds = someData
}
catch
{
//Handle some error
}
finally
{
ds = null;
}return ds;
}
A simple programming oversight. :laugh:
So the creationist says: Everything must have a designer. God designed everything. I say: Why is God the only exception? Why not make the "designs" (like man) exceptions and make God a creation of man?
-
A programmer told me he just learned try...catch, and found it's very powerful. Later, he found one of his methods always return null after he implemented try...catch. Here is his code:
private DataSet GetData()
{
DataSet ds = null;
try
{
ds = new DataSet();
//Get data
//And assign ds = someData
}
catch
{
//Handle some error
}
finally
{
ds = null;
}return ds;
}
:doh:
How many bytes of text have I typed in my lifetime??? Man, I wish I kept track...
-
A programmer told me he just learned try...catch, and found it's very powerful. Later, he found one of his methods always return null after he implemented try...catch. Here is his code:
private DataSet GetData()
{
DataSet ds = null;
try
{
ds = new DataSet();
//Get data
//And assign ds = someData
}
catch
{
//Handle some error
}
finally
{
ds = null;
}return ds;
}
His purpose was to clear object DataSet in section finally. But, do you guys think the DataSet will be cleared if no error is caught?
private bool CheckData()
{
DataSet ds = null;
try
{
//Get Data, and fill ds
//if there is data in the ds's table
return true;
}
catch{}
finally
{
ds = null;
}return false;
}
-
His purpose was to clear object DataSet in section finally. But, do you guys think the DataSet will be cleared if no error is caught?
private bool CheckData()
{
DataSet ds = null;
try
{
//Get Data, and fill ds
//if there is data in the ds's table
return true;
}
catch{}
finally
{
ds = null;
}return false;
}
Uhh...yes? That's the entire point of the Finally... statement. :doh:
“Acer, Gateway, and eMachines are the same company now. Great! Now we just need a really big toilet, and we can get rid of all three at once.”
-
"A little knowledge is a dangerous thing." -- Alexander Pope
Just to be pedantic - Pope's quotation is actually "A little learning is a dangerous thing"
==================================== Transvestites - Roberts in Disguise! ====================================
-
That said, I suggest you and your cow-orker might want to start by learning what the finally block does.
Today's lesson is brought to you by the word "niggardly". Remember kids, don't attribute to racism what can be explained by Scandinavian language roots. -- Robert Royall