Click here to Skip to main content
15,887,353 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am using ADO.net to retrieve couple of text field's data from SQL server based on a text field data which I have already. Now When I am trying to query the database , having issue like Must declare the scalar variable .

What I have tried:

using (SqlCommand cmd = new SqlCommand("Select * from tblAcc where " + " uid = @txtsysuser", conn))
Posted
Updated 14-May-19 9:05am
v2

1 solution

You are specifying a parameter, but then not supplying it.
C#
using (SqlCommand cmd = new SqlCommand("Select * from tblAcc where uid = @txtsysuser", conn))
   {
   cmd.Parameters.AddWithValue("@txtsysuser", valueToCompareTheUIDTo);
   ...
   }
 
Share this answer
 

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