How to update dataset ?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sameerdev
    New Member
    • Nov 2010
    • 2

    #1

    How to update dataset ?

    Hi,

    I want to fetch record multiple from tables (present month). I am sending to u code Problem is in bold section.

    Question is that how can update dataset & dataadipter ?





    string month = DateTime.Now.Mo nth.ToString();
    string year = DateTime.Now.Ye ar.ToString();
    string days = DateTime.DaysIn Month(Convert.T oInt32(year),Co nvert.ToInt32(m onth)).ToString ();
    cmd = new SqlCommand("sel ect (quoteno) from quotation where quotedate>='" + month + "/1/" + year + "' and quotedate>='" + month + "/" + days + "/" + year + "' order by QuoteDate", con);

    con.Open();
    ArrayList arr = new ArrayList();
    dr = cmd.ExecuteRead er();

    while (dr.Read())
    {
    arr.Add(dr[0].ToString());
    }

    dr.Close();

    for (int i = 0; i < arr.Count; i++)
    {
    cmd = new SqlCommand("sel ect a.quoteno as quoteno, b.firstname as client, c.materialcost as meterial, c.deliverycost as delivery, c.CouncilCost as Council, c.Miscellaneous Cost as misc, c.TotalCost as GrossProfit from quotation a, client b , cost c, construction d where a.quoteno= '" + arr[i].ToString() + "' and c.quoteno= '" + arr[i].ToString() + "' and d.quoteno='" + arr[i].ToString() + "' and a.CleintCode= b.CleintCode", con);
    MyDA.SelectComm and = cmd;
    //This is our DataSet created at Design Time
    MyDA.Fill(myDS, "MonthEndReport Table");
    }

    //You have to use the same name as that of your Dataset that you created during design time
    MEDR oRpt = new MEDR();
    // This is the Crystal Report file created at Design Time
    oRpt.SetDataSou rce(myDS);
    // Set the SetDataSource property of the Report to the Dataset
    crystalReportVi ewer1.ReportSou rce = oRpt;
    // Set the Crystal Report Viewer's property to the oRpt Report object that we created
    crystalReportVi ewer1.Refresh() ;
    con.Close();
Working...