problem in there is no row at position 0.

Posted by Sekar.C under ASP.NET on 3/3/2012 | Points: 10 | Views : 4725 | Status : [Member] | Replies : 2
sir,

How to solve this problem in there is no row at position 0.
I create web application using web service
localhost.WebService s = new localhost.WebService();

DataSet ds = s.serverstatuspasient1(nymbleticket, Servername);

string sts = ds.Tables[0].Rows[0].ItemArray[0].ToString();

comes this error:
there is no row at position 0.

regard
sekar.c

Regards
Sekar.c



Responses

Posted by: Vuyiswamb on: 3/3/2012 [Member] [MVP] [Administrator] NotApplicable | Points: 25

Up
0
Down
Before you access the value in your data table check if the dataset returned data

string sts = string.empty;

if(ds.tables[0].rows.count> 0)
{

sts = ds.Tables[0].Rows[0].ItemArray[0].ToString();
}


Thank you for posting at Dotnetfunda
[Administrator]

Sekar.C, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: perfectchourasia-9163 on: 3/5/2012 [Member] Starter | Points: 25

Up
0
Down
Use If else In such a way that everything clear data exist in or not.

ER sandeep chourasia
sandeepchrs@yahoo.com (on facebook)
http://www.aspnetcodes.com/

Sekar.C, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response