Record Insertion Problem

  • HI There,

    I am using SQL Server 2005 and C#.Net 2005 as a front end.

    I have written stored procedure to insert record into table. In that table i have field named 'TARIFF_CODE' with type 'Varchar' and size 15.

    I have also written front end code with Sqlcommand object to call this sp and passed all proper required parameter values.

    ICDPara = new SqlParameter();

    ICDPara.ParameterName = "@Tariff_code";

    ICDPara.Direction = ParameterDirection.Input;

    ICDPara.SqlDbType = SqlDbType.VarChar;

    ICDPara.Value = Tariff_code_act; --------------------> [e.g TR000012].

    ICDPara.Size = 15;

    ICDCmd.Parameters.Add(ICDPara);

    But when i execute it and see it in Database i got only first 5 chars for pass value for field 'TARIFF_CODE'.

    Insterestingly, it wont happens when i execute that SP through SSMS.

    Please help me out.

    Regards And Thanks

  • Hi Anup,

    I would suggest you try increasing the size of the parameter from 15 to any greater value having sufficient difference say 50 or 100.

    Hope this would help,

    Regards

    Avaneesh Bajoria

  • check you parameter declartions both in yur C# code as well as your procedure.

    "Keep Trying"

  • I generally define input parms like so:

    cmd.Parameters.AddWithValue("@TariffCode", TariffCode);

    And I don't specify the size of the parameter.

    There is no "i" in team, but idiot has two.

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply