+ Post New Thread
Results 1 to 3 of 3
Web Development Thread, Error:Must declare the scalar variable "@". in Coding and Web Development; the problem is here Code: public static List<TRS_LUT_CLIENTS> GetClientByStaffId(string STAFF_CL) { List<TRS_LUT_CLIENTS> clients = new List<TRS_LUT_CLIENTS>(); SqlCommand selectCmd = new ...
  1. #1

    Join Date
    Sep 2013
    Posts
    3
    Thank Post
    1
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Error:Must declare the scalar variable "@".

    the problem is here

    Code:
     public static List<TRS_LUT_CLIENTS> GetClientByStaffId(string STAFF_CL)
            {
                List<TRS_LUT_CLIENTS> clients = new List<TRS_LUT_CLIENTS>();
                SqlCommand selectCmd = new SqlCommand("select * from TRS_LUT_CLIENT C, TRS_TASKS T where C.CLIENT_ID = T.CLIENT_ID and  T.STAFF_CL = @ STAFF_CL");
                selectCmd.Parameters.Add("STAFF_CL", SqlDbType.NVarChar).Value = STAFF_CL;
                
                DataTable dt = DBManager.ExecuteQuery(selectCmd);
                foreach (DataRow row in dt.Rows)
                {
                    clients.Add(new TRS_LUT_CLIENTS(int.Parse(dt.Rows[0]["CLIENT_ID"].ToString()), dt.Rows[0]["CLIENT_NAME"].ToString(), dt.Rows[0]["CLIENT_ADDRESS"].ToString(), dt.Rows[0]["CLIENT_DESCRIPTION"].ToString()));
                }
                return clients;
            }
    i can't c it at all !! i thought that it may be the parameters.add . but what exactly i don't know !!
    Last edited by pansy; 30th September 2013 at 02:37 AM.

  2. #2

    Join Date
    May 2010
    Posts
    1,017
    Thank Post
    105
    Thanked 76 Times in 62 Posts
    Rep Power
    47
    It wouldn't be the space here would it ?

    @ STAFF_CL should be @STAFF_CL ? or no @ at all, been a while since I did sql and I did it all with stored procs too.
    Last edited by caffrey; 30th September 2013 at 06:32 AM.

  3. Thanks to caffrey from:

    pansy (30th September 2013)

  4. #3

    Join Date
    Sep 2013
    Posts
    3
    Thank Post
    1
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    i solved by removing the cmd.parameters.add to addvalue and it's works
    Thank you

SHARE:
+ Post New Thread

Similar Threads

  1. Replies: 2
    Last Post: 7th January 2013, 01:58 PM
  2. [Website] Russian Page Not Found Error Page [Turn The Sound Down]
    By DaveP in forum Jokes/Interweb Things
    Replies: 1
    Last Post: 2nd February 2012, 07:40 AM
  3. [ASP.net] Must declare the scalar variable "@Name".
    By damienharrison in forum Web Development
    Replies: 3
    Last Post: 30th May 2010, 07:02 PM
  4. [News] This must make the News Quiz
    By laserblazer in forum Jokes/Interweb Things
    Replies: 5
    Last Post: 30th March 2010, 12:19 PM
  5. It must be the end of term because....
    By witch in forum General Chat
    Replies: 23
    Last Post: 18th December 2009, 08:49 AM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •