T
tdmailbox
I had some code that returns a random record for a recordset. It works
fine unless my record set has one value. So as a solution I tried to
wrap the whole thing inside an If statement so that it was only called
if the record count was bigger then 1.
However when I made that I change I get the error that "The name
'strHTMLPage' does not exist in the class or namespace." If appears
that if my variable is declared inside the If statement it throws and
error each time the variable is called further down in the application.
Any idea how I can fix this?
-----
Random randObj = new Random(DateTime.Now.Second);
int num = randObj.Next(alURL.Count - 1) + 1;
string strHTMLPage = readHtmlPage(alURL[num].ToString());
----------
Random randObj = new Random(DateTime.Now.Second);
if (alURL.Count > 1)
{
int num = randObj.Next(alURL.Count - 1) + 1;
string strHTMLPage = readHtmlPage(alURL[num].ToString());
}
else
{
string strHTMLPage = readHtmlPage(strURL);
}
fine unless my record set has one value. So as a solution I tried to
wrap the whole thing inside an If statement so that it was only called
if the record count was bigger then 1.
However when I made that I change I get the error that "The name
'strHTMLPage' does not exist in the class or namespace." If appears
that if my variable is declared inside the If statement it throws and
error each time the variable is called further down in the application.
Any idea how I can fix this?
-----
Random randObj = new Random(DateTime.Now.Second);
int num = randObj.Next(alURL.Count - 1) + 1;
string strHTMLPage = readHtmlPage(alURL[num].ToString());
----------
Random randObj = new Random(DateTime.Now.Second);
if (alURL.Count > 1)
{
int num = randObj.Next(alURL.Count - 1) + 1;
string strHTMLPage = readHtmlPage(alURL[num].ToString());
}
else
{
string strHTMLPage = readHtmlPage(strURL);
}