i am validating whether the user enters in the textbox1 student id is there in the database or not.
for that code as follows;
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();
if (count > 0)
{
Label4.Text = "Correct Student id";
return;
}
else
{
Label4.Text = "InCorrect student id is there";
return;
}
SCon.Con.Close();
in the run mode when i enters the student id in the textbox1 and click the button shows error as follows;
input string was not in a correct format
what is the problem in my above code please help me.
Regards,
Narasiman P.