日期:2014-05-18  浏览次数:20489 次

如何调用存储过程
名字为 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
……