Call a stored procedure : SqlConnection Stored Procedure : ADO.Net C# Examples


C# Examples » ADO.Net » SqlConnection Stored Procedure »

 

Call a stored procedure









    
using  System;
using  System.Data;
using  System.Data.SqlClient;

class  MainClass
{
    static  void  Main(string[]  args)
    {
        SqlConnection  cn  =  new  SqlConnection("Data  Source=(local);  Initial    Catalog  =  MyDatabase;  User  ID=sa;Password=");
        SqlCommand  cmd  =  new  SqlCommand("MyStoredProcedure",  cn);
        cmd.CommandType  =  CommandType.StoredProcedure;
        SqlParameter  param  =  new  SqlParameter("@ReturnValue",  SqlDbType.Int);
        cmd.Parameters.Add(param);
        cmd.Parameters.Add("MyFirstParameter",  SqlDbType.Int);
        cmd.Parameters.Add("MySecondParameter",  SqlDbType.Int).Direction  =
        ParameterDirection.Output;
        SqlDataAdapter  da  =  new  SqlDataAdapter(cmd);
        
    }
}
    
   
  
   




HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo ADO.Net
» SqlConnection Stored Procedure