public void SqlServerHelperForExcueteProcTest() { SqlParameter[] sqlParameters = { new SqlParameter() { ParameterName = "NAME", Direction = System.Data.ParameterDirection.Input, Value = "dsfd" }, new SqlParameter() { ParameterName = "ReturnValue", Direction = System.Data.ParameterDirection.ReturnValue } }; helper.ExceuteNoneQuery("ProcTest", System.Data.CommandType.StoredProcedure, sqlParameters); var result = sqlParameters[1].Value; }
public bool AddNews(NewsInfo news) { string sql = "INSERT INTO TB_NEWS(Title,Content,CreateDate,Author) VALUES(@Title,@Cotent,@CreateDate,@Author)"; SqlParameter[] sqlParameters = { new SqlParameter("Title", System.Data.SqlDbType.NVarChar), new SqlParameter("Content", System.Data.SqlDbType.NVarChar), new SqlParameter("CreateDate", System.Data.SqlDbType.DateTime), new SqlParameter("Author", System.Data.SqlDbType.Int) }; sqlParameters[0].Value = news.Title; sqlParameters[1].Value = news.Content; sqlParameters[2].Value = news.CreateDate; sqlParameters[3].Value = news.Author; return(sqlHelper.ExceuteNoneQuery(sql, System.Data.CommandType.Text, sqlParameters) > 0); }