Vindhya Yadaav

Vindhya Yadaav

  • NA
  • 36
  • 10.5k

Sql query not working

Dec 1 2015 5:38 AM

SqlDataAdapter sda = new SqlDataAdapter("select scode from result where Enrollno ='" + Label7.Text + "'", con);

DataTable dt = new DataTable();

sda.Fill(dt);

int c = dt.Rows.Count;

if (c != 0)

{

Label8.Text ="Sorry You Have been already Given Exam";

}

Its not working
when i given Not paper1 (scode) its works and insert command .
after that when i want given paper2(scode) its say Sorry You Have been already Given Exam";
but i not given paper2.
One Enrollment No. also give paper1 and paper2, paper3 how....?
 
else

{

SqlCommand cmd = new SqlCommand("insert into result(Enrollno,scode,TotalQuestion,TotalCorrectAnswer,TotalWrongAnswer,Examdate) values (" + Label7.Text + ",'" + DropDownList1.Text + "','" + a + "','" + count + "','" + b + "','" + Label5.Text + "')", con);

con.Open();

cmd.ExecuteNonQuery();

con.Close();

}


Answers (8)