日期:2014-05-17 浏览次数:20493 次
public static int ExcuteNonQuery(string sqlcmd, SqlParameter[] Parameter) { SqlConnection conn = new SqlConnection(SqlConn); if(conn.State!=ConnectionState.Open) { conn.Open(); } SqlCommand cmd = new SqlCommand(); cmd.Connection = conn; cmd.CommandText = "st_register"; cmd.CommandType = CommandType.StoredProcedure; if (Parameter != null) { foreach (SqlParameter item in Parameter) { cmd.Parameters.Add(item); } } return cmd.ExecuteNonQuery(); }
public int CreateStudent(M_Student m_student) { return SQLHelper.ExcuteNonQuery("st_register", new SqlParameter[] { new SqlParameter("@uname",m_student.Uname), new SqlParameter("@password",m_student.Password), new SqlParameter("@tel",m_student.Tel), new SqlParameter("@sex",m_student.Sex), new SqlParameter("@address",m_student.Address) }); }
create procedure st_register @uname varchar(50), @password varchar(50), @tel varchar(50), @sex bit, @address varchar(50) as insert into Stu(uname,password,tel,sex,address)values(@uname,@password,@tel,@sex,@address)