how to use stored procedure in a asp.net

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sridhar21
    New Member
    • Feb 2007
    • 26

    how to use stored procedure in a asp.net

    Hai to all

    i am sridhar


    i have one doubt

    how to use stored procedure in a asp.net

    wait for your reply
  • shweta123
    Recognized Expert Contributor
    • Nov 2006
    • 692

    #2
    Hi,

    This is the example of how you can call the procedure-
    Lets say procedure is Proc1(p1 nvarchar(50),p2 int out)

    Dim con as New OleDb.OleDbConn ection
    Dim com As New OleDb.OleDbComm and

    con.ConnectionS tring="SQLOLEDB .1;Persist Security Info=True;User ..........."

    con.open


    'Declare the parameters
    Dim pin As New OleDb.OleDbPara meter 'Input Parameter
    Dim pout As New OleDb.OleDbPara meter 'Output Parameter

    pin.Direction = ParameterDirect ion.Input
    pin.ParameterNa me = "p1"
    pin.Size = 50
    pin.DbType = DbType.String

    pout.Direction = ParameterDirect ion.Output
    pout.ParameterN ame = "p2"
    pout.DbType = DbType.Int32

    com.Parameters. Add(pin)
    com.Parameters. Add(pout)

    com.CommandType = CommandType.Sto redProcedure

    'Here give the procedure Name
    com.CommandText = "Proc1"
    com.ExecuteNonQ uery()

    'Get the value from pout as pout.Value

    Shweta

    Comment

    Working...