Hi,
I am using VS2008 C#. I have manually created a typed dataset "DataSet1" then drag drop a table from an Access db.
I want to populate this "DataSet1" from another dataset "dt" so that I can modify the data into a form suitable for CrystalReport "rpt". The crystal report uses the same "DataSet1" as data source.
If I use this code compiler error says "newDr" in second line is unassigned
DataSet1.ScoreC ardTblRow newDr;
newDr.Community Name = dr["Community"].ToString();
If I use this compiler error says first line needs a type conversion
newDr = ds.ScoreCardTbl .NewRow();
newDr.Community Name = dr["Community"].ToString();
Anyone know what I should do?
Here is the complete code
Denis
I am using VS2008 C#. I have manually created a typed dataset "DataSet1" then drag drop a table from an Access db.
I want to populate this "DataSet1" from another dataset "dt" so that I can modify the data into a form suitable for CrystalReport "rpt". The crystal report uses the same "DataSet1" as data source.
If I use this code compiler error says "newDr" in second line is unassigned
DataSet1.ScoreC ardTblRow newDr;
newDr.Community Name = dr["Community"].ToString();
If I use this compiler error says first line needs a type conversion
newDr = ds.ScoreCardTbl .NewRow();
newDr.Community Name = dr["Community"].ToString();
Anyone know what I should do?
Here is the complete code
Code:
DbOperation dbOp = new DbOperation();
DataSet1 ds = new DataSet1();
CrystalReport1 rpt = new CrystalReport1();
DataSet1.ScoreCardTblRow newDr;
protected void Page_Load(object sender, EventArgs e)
{
DataTable dt;
string sql = "SELECT * FROM ScoreCard";
dt = dbOp.GetDataSet(sql).Tables[0];
foreach (DataRow dr in dt.Rows)
{
[B]newDr = ds.ScoreCardTbl.NewRow();[/B]
newDr.CommunityName = dr["Community"].ToString();
rpt.Rows.Add(newDr);
}
}
Comment