I get an error of conversion of nvarchar to int. I also tried parsing but it does not solve my problem. So how can I solve that problem??
this is my stored procedure that has a int parameter :
ALTER PROCEDURE [dbo].[Student_Registration] @SSID int
AS
SELECt TRoom ,DayWeek,ET ,ST ,LNProfessor ,NProfessor ,Code , TLesson ,'false' AS IsChecked
FROM View_1Registration
WHERE View_1Registration.SubjectStudyId=@SSID
this is my Source code:
private DataTable GetData()
{
string conString = ConfigurationManager.ConnectionStrings["KDUIS-v1ConnectionString"].ConnectionString;
SqlCommand cmd = new SqlCommand("Student_Registration");
using (SqlConnection con = new SqlConnection(conString))
{
using (SqlDataAdapter sda = new SqlDataAdapter())
{
cmd.Connection = con;
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@SSID", Convert.ToInt32( LblSubjectStudy.Text.Trim()));
sda.SelectCommand = cmd;
using (DataTable dt = new DataTable())
{
sda.Fill(dt);
return dt;
}
}
}
}
when i run my source cod i got into this error in this line of code:
cmd.Parameters.AddWithValue("@SSID", Convert.ToInt32( LblSubjectStudy.Text.Trim()));
this is an error message:
'Input string was not in a correct format.'