call存储过程(有返回值)

using  (SqlConnection sqlconn  =   new  SqlConnection( " server=.;uid=sa;pwd=yuling1310;database=smls " ))
            {
                SqlCommand sqlcmd 
=   new  SqlCommand( " getcerti_notesbigtext " , sqlconn);
                sqlcmd.CommandType 
=  CommandType.StoredProcedure;
                
// 输入参数
                sqlcmd.Parameters.Add( " p_certi_type_code " , SqlDbType.VarChar,  10 ).Value  =   " x " ;
                sqlcmd.Parameters.Add(
" p_order_no " , SqlDbType.VarChar,  50 ).Value  =   " SBF55YQ001 " ;
                sqlcmd.Parameters.Add(
" @p_certi_no " , SqlDbType.VarChar,  50 ).Value  =   " 00000155 " ;
                sqlcmd.Parameters.Add(
" @a_certi_sheet_type_code " , SqlDbType.VarChar,  10 ).Value  =   " 1 " ;

                
// 输出参数
                sqlcmd.Parameters.Add( " @text1 " , SqlDbType.VarChar,  200 );
                sqlcmd.Parameters[
" @text1 " ].Direction  =  ParameterDirection.Output;

                sqlcmd.Parameters.Add(
" @text2 " , SqlDbType.VarChar,  200 );
                sqlcmd.Parameters[
" @text2 " ].Direction  =  ParameterDirection.Output;

                sqlcmd.Parameters.Add(
" @text3 " , SqlDbType.VarChar,  200 );
                sqlcmd.Parameters[
" @text3 " ].Direction  =  ParameterDirection.Output;

                sqlcmd.Parameters.Add(
" @text4 " , SqlDbType.VarChar,  200 );
                sqlcmd.Parameters[
" @text4 " ].Direction  =  ParameterDirection.Output;

                sqlconn.Open();
                sqlcmd.ExecuteNonQuery();

                
string  str  =  sqlcmd.Parameters[ " @text1 " ].Value.ToString();
                sqlconn.Close();
            }

SqlParameter[] param  =  {  new  SqlParameter( " @userid " , SqlDbType.Char,  10 ) };
param[
0 ].Value  =  userid;

SqlParameter[] param 
=  {  new  SqlParameter( " @userid " , SqlDbType.Char,  10 ), new  SqlParameter( " @username " ,SqlDbType.Char,  15 ),.. };
param[
0 ].Value  =  userid;
param[
1 ].Value  =  username;

if  (parm  !=   null )
{
    
foreach  (SqlParameter sqlparams  in  parm)
        cmd.Parameters.Add(sqlparams);
}

你可能感兴趣的:(存储过程)