Click here to Skip to main content
15,885,914 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello
I have four Tables in my Database that they are join to gather
I want select data from my Education_TB in the manage page of user that the user logined by username and password from Login page and redirect with Query string ID to manage page.
Now when I want show the result of select statement in a from I face to this error
"
Conversion failed when converting the nvarchar value 'Hedayatullah' to data type int.
"
Please help me what I do

Here is my Sql cod and C# cod

SQL
ALTER procedure [dbo].[Select_Education_TB_Full]
@Eid int
as

begin
  select Person_Name
  ,Field_name_english
  ,SubField_Name_english
  ,Degree_Education
  ,University_Name
  ,Date_Graduated
  ,Experience_Job
  ,CV_Path 
  from Education_Degree_TB 
  inner join  Person_TB 
  on Education_Degree_TB.Person_ID=Person_TB.Person_ID 
  join  Field_TB 
  on Education_Degree_TB.Field_ID=Field_TB.Field_ID 
  join SubField_TB 
  on Education_Degree_TB.SubField_ID=SubField_TB.SubField_ID 
  where Person_Name=@Eid
end




SqlCommand cmdEdrop = new SqlCommand("Select_Education_TB_Full",con);
cmdEdrop.CommandType = CommandType.StoredProcedure;
cmdEdrop.Parameters.AddWithValue("@Eid",Request.QueryString["id"]);
con.Open();
SqlDataReader dre;
dre = cmdEdrop.ExecuteReader();

while (dre.Read())
{

    LabelName.Text=dre["Person_Name"].ToString();
    DropDegree.SelectedValue=dre["Field_Name_English"].ToString();
    DropField.SelectedValue=dre["SubField_Name_English"].ToString();
    DropQualification.SelectedValue= dre["Degree_Education"].ToString();
    LabelUniversity.Text=dre["University_Name"].ToString();
    LabelGraduated.Text=dre["Date_Graduated"].ToString();
    DropExperience.Text=dre["Experience_Job"].ToString();
    LabelCV.Text=dre["CV_Path"].ToString();
}
con.Close();//------------------
Posted
Updated 19-Jan-15 11:30am
v2
Comments
PIEBALDconsult 19-Jan-15 17:28pm    
SQL Server? Does the procedure work in SSMS?

1 solution

@Eid int ... where Person_Name=@Eid

I think you want to change the definition of the parameter.
 
Share this answer
 
Comments
Member 11240896 19-Jan-15 17:43pm    
No sir
I want show the information of that user that the user login and redirect by Query string to the manage page. just one user
PIEBALDconsult 19-Jan-15 17:46pm    
Yes, but the procedure expects an int -- yet you are sending it a string and that would be OK if the string can be converted to an int, but it can't. Please check with a debugger.
Member 11240896 19-Jan-15 17:52pm    
Did you see my C# cod?
I check it with debugger but I can't find the problem
PIEBALDconsult 19-Jan-15 17:58pm    
I don't think it's the C# code; I think it's the procedure.
Is the value for @Eid from the URL that is being passed into the procedure 'Hedayatullah' ?
Member 11240896 19-Jan-15 18:11pm    
yes that is right.
Now please find the problem.
How converting the nvarchar value 'Hedayatullah' to data type int?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900