Sunday, January 11, 2009

Call a stored procedure tutorial example

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);

}
}

0 comments:

Followers

The Daily Puppy

 
Design by Wordpress Theme | Bloggerized by Free Blogger Templates | JCPenney Coupons