if (dpsessional.SelectedItem.Text.ToString().Equals("1"))
{
if (lengthofbatch == 1)
{
com = new SqlCommand("insert into Attendence_Stu_Main(st_id,st_rollno,st_name,branch_name,sem_no,batch_year,batch_name,scode,sess_no,attendence,total) values (@Stid,@Strollno,@Stname,@Stbranch,@Ssemno,@Syear,@Sbatch,@Scode,@Ssessno,@Satt,@Stotal)", con);
}
else
{
if (lbsubjecttype.Text.Equals("L"))
{
com = new SqlCommand("insert into Attendence_Stu_Main(st_id,st_rollno,st_name,branch_name,sem_no,batch_year,batch_name,scode,sess_no,attendence,total) values (@Stid,@Strollno,@Stname,@Stbranch,@Ssemno,@Syear,firstchar,@Scode,@Ssessno,00,00)", con);
com = new SqlCommand("insert into
Attendence_Stu_MainL1(st_id,st_rollno,st_name,branch_name,sem_no,batch_year,batch_name,scode,sess_no,attendence,total) 値
(@Stid,@Strollno,@Stname,@Stbranch,@Ssemno,@Syear,@Sbatch,@Scode,@Ssessno,@Satt,@Stotal)",
コン); } そうしないと
{
com = new SqlCommand("insert into
Attendence_Stu_MainL1(st_id,st_rollno,st_name,branch_name,sem_no,batch_year,batch_name,scod
e,sess_no,attendence,total) 値
(@Stid,@Strollno,@Stname,@Stbranch,@Ssemno,@Syear,@Sbatch,@Scode,@Ssessno,@Satt,@Stotal)",
コン);
}
}
}
com.Parameters.AddWithValue("@Stid", g1.Cells[0].Text);
com.Parameters.AddWithValue("@Strollno", g1.Cells[1].Text); com.Parameters.AddWithValue("@Stname", g1.Cells[2].Text);
com.Parameters.AddWithValue("@Stbranch", g1.Cells[3].Text);
com.Parameters.AddWithValue("@Ssemno", g1.Cells[4].Text);
com.Parameters.AddWithValue("@Syear", g1.Cells[5].Text);
com.Parameters.AddWithValue("@Sbatch", label1);
com.Parameters.AddWithValue("@Scode", label2);
com.Parameters.AddWithValue("@Ssessno", label3);
com.Parameters.AddWithValue("@Satt", textbox);
com.Parameters.AddWithValue("@Stotal", textbox1);
com.ExecuteNonQuery();
con.Close();
}
catch (SqlException ex)
{
Label5.Text = ex.Message;
Label5.Visible = true;
}
}
}
................................................................... ...................................................
com = new SqlCommand("Insert into Attendence_Stu_Main(st_id,st_rollno,st_name,branch_name,sem_no,batch_year,batch_name,scode, sess_no,attendence,total) 値 (@Stid,@Strollno,@Stname,@Stbranch,@Ssemno,@ Syear,firstchar,@Scode,@Ssessno,00,00)", con);
com = new SqlCommand("insert into
Attendence_Stu_MainL1(st_id,st_rollno,st_name,branch_name,sem_no,batch_year,batch_name,scod
e,sess_no,attendence,total) 値
(@Stid,@Strollno,@Stname,@Stbranch,@Ssemno,@Syear,@Sbatch,@Scode,@Ssessno,@Satt,@Stotal)",
コン);
挿入コマンドの2つから、1つだけが起動され、他は起動されません..私は使用してみました
デバッグ中、明確なトラバースが表示されますが、テーブルに保存できません