当前位置: 代码迷 >> ASP.NET >> 怎么调用存储过程
  详细解决方案

怎么调用存储过程

热度:5991   发布时间:2013-02-25 00:00:00.0
如何调用存储过程
名字为 a 带传入参数的存储过程
 里面 exec(select * from user where name=@name )
请问 程序里如何调用?

------解决方案--------------------------------------------------------
C# code
            SqlCommand cmd = new SqlCommand();            cmd.Connection =  conn;//数据库连接            cmd.CommandText = "exec a";             CommandType.StoredProcedure            cmd.CommandType =// type;            SqlDataAdapter da = new SqlDataAdapter(cmd);              da.Fill("table1");
------解决方案--------------------------------------------------------
SqlCommand cmd = new SqlCommand();
 cmd.Connection = conn;
cmd.CommandType=CommandType.StoreProcedure
 cmd.CommandText =存储过程名
cmd.execureScalar();
------解决方案--------------------------------------------------------
探讨
C# code


SqlCommand cmd = new SqlCommand();
cmd.Connection = conn;//数据库连接
cmd.CommandText = "exec a";
CommandType.StoredProcedure
……
  相关解决方案