Skip to content

C#,Error to getting the seven day errors

Kamala Veni

Asked Feb 26, 2016, 12:02 AM EST2 answers
Share
LinkedInX
Hi
I am Having 7 Days form with Particular field including date,day,time.
am getting the data to store in sql table,database through the form.
While am Selecting 7 days using calendar  to entry the record in the form ,
its saving only the 7Th day record,1-6 day records not store in database table?
HOW TO CLEAR THE ERROR ?
 
Ex:
 
Java
            SqlConnection cnn = new SqlConnection();
            cnn.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["cp"].ConnectionString; cnn.Open();
            SqlCommand cmd = new SqlCommand();
            cmd.CommandText = "select * from tbl_sch111";
            cmd.Connection = cnn;
            SqlDataAdapter da = new SqlDataAdapter();
            da.SelectCommand = cmd;
            DataSet ds = new DataSet();
            da.Fill(ds, "tbl_sch111");

            SqlCommandBuilder cb = new SqlCommandBuilder(da);
            DataRow drow = ds.Tables["tbl_sch111"].NewRow();
drow["Date"] = lb.Text=l.Text;
drow["Time"] = lbb.Text= l2.Text;
VB.NET
            drow["Day"] = lbd.Text= l3.Text;
            drow["blk_1"] = txtbl1.Text= TextBox1.Text;
            drow["blk_2"] = txtbl2.Text= TextBox2.Text;
            drow["blk_3"] = txtbl3.Text= TextBox3.Text;
            drow["blk_4"] = txtbl4.Text= TextBox4.Text;
            drow["blk_5"] = txtbl5.Text= TextBox5.Text;
            drow["blk_6"] = txtbl6.Text= TextBox6.Text;
            drow["blk_7"] = txtbl7.Text= TextBox7.Text;
            drow["blk_8"] = txtbl8.Text= TextBox8.Text;
            drow["blk_9"] = txtbl9.Text= TextBox9.Text;
drow["blk_10"] = txtbl10.Text= TextBox10.Text;
ds.Tables["tbl_sch111"].Rows.Add(drow);
da.Update(ds, "tbl_sch111");
 

2 Answers

Know the answer? Post it. Somebody with the same question will find it here.

  • 0
    just copy paster this part code  
     
     
     
    Code
    DataRow drow = ds.Tables["tbl_sch111"].NewRow();
    
    
    drow["Date"] = lb.Text=l.Text;
    ds.Tables["tbl_sch111"].Rows.Add(drow);
    drow = ds.Tables["tbl_sch111"].NewRow();
    drow["Time"] = lbb.Text= l2.Text;
    ds.Tables["tbl_sch111"].Rows.Add(drow);
    drow = ds.Tables["tbl_sch111"].NewRow();
     
    drow["Day"] = lbd.Text= l3.Text;
    ds.Tables["tbl_sch111"].Rows.Add(drow);
    drow = ds.Tables["tbl_sch111"].NewRow();
     
    drow["blk_1"] = txtbl1.Text= TextBox1.Text;
    ds.Tables["tbl_sch111"].Rows.Add(drow);
    drow = ds.Tables["tbl_sch111"].NewRow();
     
    drow["blk_2"] = txtbl2.Text= TextBox2.Text;
    ds.Tables["tbl_sch111"].Rows.Add(drow);
    drow = ds.Tables["tbl_sch111"].NewRow();
     
    drow["blk_3"] = txtbl3.Text= TextBox3.Text;
    ds.Tables["tbl_sch111"].Rows.Add(drow);
    drow = ds.Tables["tbl_sch111"].NewRow();
     
    drow["blk_4"] = txtbl4.Text= TextBox4.Text;
    ds.Tables["tbl_sch111"].Rows.Add(drow);
    drow = ds.Tables["tbl_sch111"].NewRow();
     
    drow["blk_5"] = txtbl5.Text= TextBox5.Text;
    ds.Tables["tbl_sch111"].Rows.Add(drow);
    drow = ds.Tables["tbl_sch111"].NewRow();
     
    drow["blk_6"] = txtbl6.Text= TextBox6.Text;
    ds.Tables["tbl_sch111"].Rows.Add(drow);
    drow = ds.Tables["tbl_sch111"].NewRow();
     
    drow["blk_7"] = txtbl7.Text= TextBox7.Text;
    ds.Tables["tbl_sch111"].Rows.Add(drow);
    drow = ds.Tables["tbl_sch111"].NewRow();
     
    drow["blk_8"] = txtbl8.Text= TextBox8.Text;
    ds.Tables["tbl_sch111"].Rows.Add(drow);
    drow = ds.Tables["tbl_sch111"].NewRow();
     
    drow["blk_9"] = txtbl9.Text= TextBox9.Text;
    ds.Tables["tbl_sch111"].Rows.Add(drow);
    drow = ds.Tables["tbl_sch111"].NewRow();
     
    drow["blk_10"] = txtbl10.Text= TextBox10.Text;
    ds.Tables["tbl_sch111"].Rows.Add(drow);
    drow = ds.Tables["tbl_sch111"].NewRow(); 
    ds.Tables["tbl_sch111"].Rows.Add(drow);
     
     
    da.Update(ds, "tbl_sch111");
    0
  • 0
    no .its saving the record properly as per date in sql
    0