Error : System.Data.DataRow

Posted by Dhivakar under Regular Expressions on 2/3/2011 | Points: 10 | Views : 1971 | Status : [Member] | Replies : 7
i have created the one page using 3 tier architecture, this page is a listing page...
at run time it doesn't display the records, where as is displays following error mess
System.Data.DataRow



guys plz help me to resolve this problem.

tnx in advance

Dhivakar.M


Responses

Posted by: Karthikanbarasan on: 2/3/2011 [Member] [Moderator] [Microsoft_MVP] [MVP] Silver | Points: 25

Up
0
Down
Hi Dhivakar,

Can you please post your code as well... this exception is generic and we need to see the inner exception as well to provide a solution for ur problem.

Thanks
Karthik
www.f5Debug.net

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

Posted by: Sathya4260 on: 2/3/2011 [Member] Starter | Points: 25

Up
0
Down
Hi Dhivakar,

Post ur coding to find whr u went wrong...

Sathish Kumar S

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

Posted by: Madhu.b.rokkam on: 2/3/2011 [Member] [MVP] Bronze | Points: 25

Up
0
Down
Please check if you have used the ToString() method with datarow object.

eg: System.Data.DataRow row = null;
if you use row.ToString ()

the you will get this.

As all suggested plese provide your sample to correct your problem.


Thanks and Regards
Madhu

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

Posted by: Dhivakar on: 2/3/2011 [Member] Starter | Points: 25

Up
0
Down
DAL code:
public static ICollection GetData()
{
DataSet ds = new DataSet();
if (!connected)
Connect();
SqlDataAdapter da = new SqlDataAdapter("", conn);
string sql = "SELECT package_id,package_name FROM tbl_packages";
//string sql = "INSERT INTO DealerLoginDetails(Dealer_no,Zipcode,dealerlevel)values FROM ";
da.SelectCommand = new SqlCommand(sql, conn);
da.Fill(ds, "tbl_packages");
return ds.Tables["tbl_packages"].Rows;
}
BAL code:
public static ICollection GetData()
{
return Dataaccessayer.newestimationDAL.GetData();
}
code behind file:
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
using businesslayer;
using Dataaccessayer;
public partial class new_estimation_step1 : System.Web.UI.Page
{

SqlConnection conn = new SqlConnection("Data Source=RHYTHA-DELL6\\SQLEXPRESS;User Id=sa;Password=rhytha268;Initial Catalog=Profussion");
protected void Page_Load(object sender, EventArgs e)
{
errormess.Visible=false;
ICollection coll = newestimationBAL.GetData();
//DataSet ds = new DataSet();
if(coll.Count>0)
{

BL_packages.DataSource = coll;
string res = coll.ToString();
Label1.Text = res;
BL_packages.DataBind();
}
else
{
errormess.Visible = true;
}

}
}
thanks for replies....


Dhivakar.M

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

Posted by: Sathya4260 on: 2/3/2011 [Member] Starter | Points: 25

Up
0
Down
Hi,

Can you explain Y u used this code,

string res = coll.ToString();
Label1.Text = res;

Sathish Kumar S

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

Posted by: Dhivakar on: 2/3/2011 [Member] Starter | Points: 25

Up
0
Down
hi sathya
its no need i forget to comment.
actually i tried to display the records in label control.....


Dhivakar.M

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

Posted by: Sathya4260 on: 2/3/2011 [Member] Starter | Points: 25

Up
0
Down
make an break point on this code
SqlDataAdapter da = new SqlDataAdapter("", conn);

and let me know whether you getting the values in dataset...

Sathish Kumar S

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

Login to post response