Hello
If you debug your project you find error on this line
int a = Convert.ToInt16(str);
because str have "
Select count(*) from Studdet where studid
"
which is never convert to int
please remove this line and execute this you get result
..
SCon.Con.Open();
string str = "Select count(*) from Studdet where studid = '" + txt_Studid.Text.ToString() + "'";
SqlCommand cmd = new SqlCommand(str, SCon.Con);
int a = Convert.ToInt16(str);
int count = (int)cmd.ExecuteScalar();
SCon.Con.Close();
if (count > 0)
{
Label4.Text = "Correct Student id";
return;
}
else
{
Label4.Text = "InCorrect student id is there";
return;
}
</pre>
thanks
and also closed connection before return because it will un-reachable code.
if problem persist please give me your reviews.,...