data lost

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Holly

    data lost

    I have a stored procedure and I called it from my c#
    application. The use case is:
    1)user selects some affiliate codes from a form.
    2)the code list, e.g.('aff1',aff 2') will be used as input
    of the stored procedure.
    Select AffiliateCode,b alance from RCS_Affiliates where
    affiliateCode in ('aff1',aff2'.. )
    2)selected code and balance will be inserted into another
    table.

    When I called my stored procedure, I have
    this problem:
    If the list has 2 elements, none is
    selected. If it has more than 2 elements, the first and
    the last one will not be selected.
    E.g. if my input
    string is 'a,b,c,d', Only b and c are handled. The stored
    procedure works fine if it is called from the SQL
    analyzer. The problem only occurs when the stored
    procedure is called from the C# application. I guess it
    is somewhere in my C# code.


    Here is the code:
    SqlCommand cmd = null;
    cmd=new SqlCommand
    ("RCS_CreateAff iliatePayouts", conn);
    cmd.CommandType = CommandType.Sto redProcedure;
    SqlParameter cons = cmd.Parameters. Add
    ("@cons",
    SqlDbType.VarCh ar, 8000);
    cons.Direction = ParameterDirect ion.Input;
    cons.Value = "'a,b,c,d'" ;
    cmd.ExecuteNonQ uery ();


    The stored procedure is like:

    CREATE PROCEDURE RCS_CreateAffil iatePayouts
    @cons varchar(8000)

    AS
    Declare @type int

    set @type=2


    INSERT RCS_Payouts
    SELECT CURRENT_TIMESTA MP,
    balance, @type, AffiliateCode
    FROM RCS_Affiliates a1
    INNER JOIN iter_charlist_t o_table(@cons, DEFAULT) s1
    ON a1.AffiliateCod e= s1.code ;
    GO

    Thanks.


Working...