首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

c#中施用存储过程

2012-08-07 
c#中使用存储过程首先创建存储过程,sql语句如下所示:SqlConnection conn_Local new SqlConnection()con

c#中使用存储过程

首先创建存储过程,sql语句如下所示:

SqlConnection conn_Local = new SqlConnection();            conn_Local.ConnectionString = "server=.;database=YCYFFJKXT;user id=sa;password=sa";            try            {                conn_Local.Open();                SqlCommand cmd_Count = new SqlCommand("Login_UserCount",conn_Local);                cmd_Count.CommandType = CommandType.StoredProcedure;                //添加输入查询参数、赋予值                cmd_Count.Parameters.Add("@ZH", SqlDbType.VarChar);                cmd_Count.Parameters.Add("@MM",SqlDbType.VarChar);                cmd_Count.Parameters["@ZH"].Value = "A";                cmd_Count.Parameters["@MM"].Value = "B";                //添加输出参数                cmd_Count.Parameters.Add("@Rowcount", SqlDbType.Int);                cmd_Count.Parameters["@Rowcount"].Direction = ParameterDirection.Output;                cmd_Count.ExecuteNonQuery();                Console.WriteLine("受影响的行数是"+cmd_Count.Parameters["@Rowcount"].Value.ToString());            }            catch (Exception ex)            {                throw ex;            }            finally            {                conn_Local.Close();            }            Console.ReadLine();


热点排行