getting output param

  • i have a select stmt in SP with a where condition

    from c# front end i am passing the condition param to SP & i waant the result fields of the same in front end

    i tried but i am geeting error as the paramater is not supplied

    this is my front end code

    SqlCommand cmdeper = new SqlCommand("usp_c_bind", con);

    cmdeper.Parameters.AddWithValue("@key",key);

    SqlDataReader dreper = cmdeper.ExecuteReader();

    if (dreper.HasRows)

    {

    while (dreper.Read())

    {

    txtlname.Text = dreper["LNAME"].ToString();

    }

    }

    SP is

    @key varchar(50)

    -- Insert statements for procedure here

    Select LNAME,LDAY,convert(varchar, ldate, 103) as ldate from CVES where LNAME= @key

  • ssurekha2000 (5/17/2012)


    i have a select stmt in SP with a where condition

    from c# front end i am passing the condition param to SP & i waant the result fields of the same in front end

    i tried but i am geeting error as the paramater is not supplied

    this is my front end code

    SqlCommand cmdeper = new SqlCommand("usp_c_bind", con);

    cmdeper.Parameters.AddWithValue("@key",key);

    SqlDataReader dreper = cmdeper.ExecuteReader();

    if (dreper.HasRows)

    {

    while (dreper.Read())

    {

    txtlname.Text = dreper["LNAME"].ToString();

    }

    }

    SP is

    @key varchar(50)

    -- Insert statements for procedure here

    Select LNAME,LDAY,convert(varchar, ldate, 103) as ldate from CVES where LNAME= @key

    Hi

    You haven't specified that the Command Type is "StoredProcedure" so in your code you should add the following:

    cmdeper.CommandType = CommandType.StoredProcedure

    Regards

    IgorMi

    Igor Micev,My blog: www.igormicev.com

  • Also, specify that your parameter is of the type output (parameter direction).

    Hope that this helps.

    - Chris

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

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