Stored procedures

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

    #1

    Stored procedures

    Hi, all!

    I would like to ask a favor regarding ADO.NET...

    I would like to know how I can access programmaticall y stored procedures in
    a SQL Server. I've been pulling my hair up all weekend, and it seems that I
    couldn't get it.

    Thanks!


  • Dishan

    #2
    Re: Stored procedures

    create
    this.m_oCommand = new SqlCommand( sStoredProcedur eName );

    // Set Command Type to StoredProcedure Command

    this.m_oCommand .CommandType = CommandType.Sto redProcedure;

    Add parameters

    oParam = new SqlParameter( "@abc", SqlDbType.Bit );

    oParam.Directio n = ParameterDirect ion.Input;

    oParam.Value = true;

    oSProc.AddParam eter( oParam );

    // Add the return value parameter( for return value)

    SqlParameter param = m_oCommand.Para meters.Add( "RETURN_VAL UE",
    SqlDbType.Int );

    param.Direction = ParameterDirect ion.ReturnValue ;

    and run command using ExecuteNonQuery . It'll return SqlParameterCol lection

    Regards

    Dishan





    "Ann Marinas" <ann_marinas@xt ra.co.nz> wrote in message
    news:e76ditIYDH A.1480@tk2msftn gp13.phx.gbl...[color=blue]
    > Hi, all!
    >
    > I would like to ask a favor regarding ADO.NET...
    >
    > I would like to know how I can access programmaticall y stored procedures[/color]
    in[color=blue]
    > a SQL Server. I've been pulling my hair up all weekend, and it seems that[/color]
    I[color=blue]
    > couldn't get it.
    >
    > Thanks!
    >
    >[/color]


    Comment

    • Marc Scheuner [MVP ADSI]

      #3
      Re: Stored procedures

      >I would like to know how I can access programmaticall y stored procedures in[color=blue]
      >a SQL Server. I've been pulling my hair up all weekend, and it seems that I
      >couldn't get it.[/color]

      1) Drop a SqlConnection on your form, and hook it up to your SQL
      database

      2) Drop a SqlCommand on your form, set the Connection property to the
      above connection, set the CommandType to
      "CommandType.St oredProcedure", set CommandText to the stored procedure
      name (e.g. "MyStoredProc") , and define the parameters the procedure
      has in the "Parameters " property

      3) Open the connection, and then either use a SqlDataAdapter to fill a
      DataTable with the output from your stored proc, or execute your
      stored proc (if it doesn't return a result set).

      Marc

      =============== =============== =============== =============== ====
      Marc Scheuner May The Source Be With You!
      Bern, Switzerland m.scheuner(at)i nova.ch

      Comment

      Working...