Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Dec 29, 2012 12:45 PM by oned_gk
Member
2 Points
18 Posts
Dec 29, 2012 11:56 AM|LINK
Hi guys,
Can one of you giude in the right direction? I don't understand why this is not working.
SqlCommand comm = new SqlCommand("SELECT tbInterestsUtilisateur.interestsID FROM tbInterestsUtilisateur INNER JOIN tbUtilisateur ON tbInterestsUtilisateur.userID = tbUtilisateur.userID WHERE (tbUtilisateur.userName = '@username')", con); SqlParameter param = new SqlParameter(); param.ParameterName = "@username"; param.Value = "rimo72"; comm.Parameters.Add(param); SqlDataReader reader = comm.ExecuteReader();
the "reader" variable is always empty.
If I put the value directly in my query, "reader" is populated.
What am I doing wrong?
Thanks
All-Star
31766 Points
6492 Posts
Dec 29, 2012 12:30 PM|LINK
Dec 29, 2012 12:36 PM|LINK
thanks it works fine now.
74 Points
37 Posts
Dec 29, 2012 12:37 PM|LINK
Hai
remove ()and ' in where condition
try it
where tbUtilisateur.userName = @username
Dec 29, 2012 12:45 PM|LINK
Rimo72
Member
2 Points
18 Posts
trouble with my SQL
Dec 29, 2012 11:56 AM|LINK
Hi guys,
Can one of you giude in the right direction? I don't understand why this is not working.
SqlCommand comm = new SqlCommand("SELECT tbInterestsUtilisateur.interestsID FROM tbInterestsUtilisateur INNER JOIN tbUtilisateur ON tbInterestsUtilisateur.userID = tbUtilisateur.userID WHERE (tbUtilisateur.userName = '@username')", con); SqlParameter param = new SqlParameter(); param.ParameterName = "@username"; param.Value = "rimo72"; comm.Parameters.Add(param); SqlDataReader reader = comm.ExecuteReader();the "reader" variable is always empty.
If I put the value directly in my query, "reader" is populated.
What am I doing wrong?
Thanks
oned_gk
All-Star
31766 Points
6492 Posts
Re: trouble with my SQL
Dec 29, 2012 12:30 PM|LINK
Rimo72
Member
2 Points
18 Posts
Re: trouble with my SQL
Dec 29, 2012 12:36 PM|LINK
thanks it works fine now.
dotnetramesh
Member
74 Points
37 Posts
Re: trouble with my SQL
Dec 29, 2012 12:37 PM|LINK
Hai
remove ()and ' in where condition
try it
oned_gk
All-Star
31766 Points
6492 Posts
Re: trouble with my SQL
Dec 29, 2012 12:45 PM|LINK