Results 1 to 2 of 2

Thread: add "N" to command Parameters

  1. #1

    Thread Starter
    Frenzied Member StrangerInBeijing's Avatar
    Join Date
    Mar 2005
    Location
    Not in Beijing
    Posts
    1,666

    add "N" to command Parameters

    as you can see in this post, I HAVE to add N in front of my varible to search on japanese or chinese.

    calling the following sproc from the QA works fine like this:
    TESTGETCAPLCO 'ja-JP', N'上海'
    (whereas TESTGETCAPLCO 'ja-JP', '上海') will return no results.

    But I want to call this stored procedure from my code. How do I add this N? I tried so many things allready, like "N" + keyword, etc:
    C# Code
    Code:
    comm = new SqlCommand("TESTGETCAPLCO", this.conn);
    comm.Parameters.Add("@lang", SqlDbType.NVarChar, 10).Value			= lang;
    comm.Parameters.Add("@keyword", SqlDbType.NVarChar, 255).Value		= keyword;
    comm.CommandType = CommandType.StoredProcedure;
    SqlDataReader reader;
    try
    {
    	reader = comm.ExecuteReader();
    STORED PROCEDURE:
    Code:
    alter proc TESTGETCAPLCO
    @lang		NVARCHAR(10),
    @keyword	NVARCHAR(255)
    AS
    set @keyword =  '%' + @keyword + '%'
    SELECT ID,
    CASE 
    	WHEN @lang = 'en-US' THEN coName_en
    	WHEN @lang = 'ja-JP' THEN coName_ja
    	WHEN @lang = 'zh-CN' THEN coName_zh
    END
    AS coName
    FROM tblCAPLCompanies
    WHERE 
    CASE 
    	WHEN @lang = 'en-US' THEN coName_en
    	WHEN @lang = 'ja-JP' THEN coName_ja
    	WHEN @lang = 'zh-CN' THEN coName_zh 
    END
    LIKE  @keyword

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: add "N" to command Parameters

    What does the N actually mean? I'm going to make a slightly educated guess and say that you'll have to set the LocaleId property of the parameter.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

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



Click Here to Expand Forum to Full Width