//Connection
SqlConnection con = new SqlConnection();
con.ConnectionString = ConfigurationManager.ConnectionStrings["연결문자열"].ConnectionString;
con.Open();

//Command 
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;

//사용할 프로시저
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "sp 이름";                          

//입력 파라미터
cmd.Parameters.AddWithValue("@param1", "1234");
cmd.Parameters.AddWithValue("@param2", "5678");

//출력 파라미터
cmd.Parameters.Add("@out_param1", 디비타입.출력형식, 길이).Direction = ParameterDirection.Output;
cmd.Parameters.Add("@out_param2", 디비타입.출력형식, 길이).Direction = ParameterDirection.Output;
        
//출력 파라미터 사용 예
cmd.Parameters.Add("@a", SqlDbType.VarChar, 9).Direction = ParameterDirection.Output;
cmd.Parameters.Add("@b", SqlDbType.VarChar, 255).Direction = ParameterDirection.Output;

[출처] Captain Of my Soul is JH
Posted by bboks.net

댓글을 달아 주세요