创建存储过程

use SMDB
go
if exists(select * from sysobjects where name = 'use_AddStudent')
drop procedure use_AddStudent
go
create procedure usp_AddStudent
@StudentName varchar(20),
@Gender char(2),
@Birthday datetime,
@StudentIdNo numeric(18,0),
@Age int,
@PhoneNumber varchar(50),
@StudentAddress varchar(500),
@CardNo varchar(20),
@ClassId int,
@Stuimage text
as 
    insert into Students(StudentName,StudentIdNo,Gender,Age,Birthday,PhoneNumber,StudentAddress,CardNo,ClassId,StuImage)
    values(@StudentName,@StudentIdNo,@Gender,@Age,@Birthday,@PhoneNumber,@StudentAddress,@CardNo,@ClassId,@StuImage)
go

public int UpdateByProcedure(string procedureName,SqlCommand[] param)
        {
            SqlConnection conn = new SqlConnection(connString);
            SqlCommand cmd = new SqlCommand();
            try
            {
                conn.Open();
                cmd.Connection = conn;
                cmd.CommandType = CommandType.StoredProcedure; //存储过程执行
                cmd.CommandText = procedureName;
                cmd.Parameters.AddRange(param);
                int result = cmd.ExecuteNonQuery();
                return result;
            }
            catch (Exception ex)
            {

                throw;
            }
        }