none
Connection using odbc or oledb for executing the procedure which has one input and one output parameter using DSN RRS feed

  • Question

  •  

    Hi everybody,

    I am connecting the db using DSN. eg) "DNS=Name;uid=sa;pwd=sa".

    I am executing the procedure that has a input parameter and one output parameter.

    I have added the parameters and i can view in quick watch also.

    But when i execute the procedure it tells that "this procedure expects input parameter".

    I tried with odbc and oledb connection since only those supports DSN.

     

    Can any one send me the sample code with

    one simple procedure which has one input and one output parameters along with the

    code how to implement this logic..?

     

    Regards,

    Chakravarthy.

    Wednesday, September 19, 2007 11:18 AM

All replies

  • Depends upon the database you are working with. Not all databases implement the same syntax so you may want to post additional information, including the code you are currently using.

    Wednesday, September 19, 2007 12:38 PM
  •  

    This is the procedure i am working....
     
    create procedure up_Retrive
    (
    @input  varchar(25),
    @outvar  int
    )
    as
    begin
     
    select @outvar = emp_id from employee
    where name = @input
     
    end
     
     
    code
    OdbcConnection con = new OdbcConnection("dsn=base;uid=sa;pwd=sa");
    con.open();
    string strcmd = "up_retrive";
    OdbcCommand cmd = new OdbcCommand(strcmd,con);
    cmd.CommandType = CommandType.StoredProcedure;
    OdbcParameter[] par = new OdbcParameter[2];
    par.ParameterName="@In_val";
    par.OdbcType = OdbcType.varchar;
    par.Direction = System.Data.Parameter.DIrection.Input;
    par.Value = val;
    cmd.ExecuteNonQuery();
     
    THe below is the other sample code i used.
     
    OdbcConnection con = new OdbcConnection("dsn=base;uid=sa;pwd=sa");
    con.open();
    string strcmd = "up_retrive";
    OdbcCommand cmd = new OdbcCommand(strcmd,con);
    cmd.CommandType = CommandType.StoredProcedure;
    cmd.Parameters.Add(new OdbcParameter("@IN_VAL",OdbcType.Varchar,300));
    cmd.Parameters[0].Value = val;
    cmd.ExecuteNonQuery();
     
     
    The above both the codes when executing tells the input parameter is not supplied....
     
    Plz help me out....
     
    Regards,
    Chakravarthy.
    Friday, September 21, 2007 5:23 AM