Click here to Skip to main content
15,884,298 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi
I have many tables in my DB all of the tables are join together
I write the below procedure for selecting the record from four tables that they are inner join together
the result of this cod return all records, but I want select just one record where Person_Name equal to an input parameter or query string in C#
In the C# part I want take Person_Name from a Query String
How I do it?
thanks
SQL
CREATE procedure [dbo].[Select_Education_TB_Full]
@Eid nvarchar(100)
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


C# code from OP's other post
SQL
SqlCommand cmdEdrop = new SqlCommand("Select_Education_TB_Full",con);
cmdEdrop.CommandType = CommandType.StoredProcedure;
con.Open();
cmdEdrop.Parameters.AddWithValue("@Eid",Request.QueryString["id"]);
SqlDataReader dre;
dre = cmdEdrop.ExecuteReader();

while (dre.Read())
{

    LabelName.Text=dre["Person_Name"].ToString();
    LblDegree.Text = dre["Field_Name_English"].ToString();
    LblField.Text = dre["SubField_Name_English"].ToString();
    LblQualifcation.Text = dre["Degree_Education"].ToString();
    LabelUniversity.Text=dre["University_Name"].ToString();
    LabelGraduated.Text=dre["Date_Graduated"].ToString();
    LblQualifcation.Text=dre["Experience_Job"].ToString();
    LabelCV.Text=dre["CV_Path"].ToString();
}
con.Close();//------------------

See also comments on repost at How to select a record in T_SQL useing stored procedure[^]
Posted
Updated 2-Feb-15 1:43am
v5
Comments
Zoltán Zörgő 1-Feb-15 14:09pm    
1) Ok, and which field is UserID here? Person_ID? Are aware that you are filtering on Person_Name field?
2) This is T-SQL so far, are are you stucked with the C# part?
Member 11240896 2-Feb-15 2:05am    
Yes, Person_ID is userID but I want filtering on Person_Name
In the C# part I want take Person_Name from a Query string
thanks
Zoltán Zörgő 2-Feb-15 3:45am    
1) Ok but this means your query is wrong.
2) And what is your problem, question? What have you tried, where are you stucked?
Member 11240896 2-Feb-15 3:56am    
I want input parameter take the value from a query string
Zoltán Zörgő 2-Feb-15 4:46am    
I got that. But there are plenty of options for accessing data. Which one do you use? ADO.NET? How does the code looks like where you want to call this?

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