您的位置:首页 > 数据库

c#使用存储过程返回数据集(SqlCommand->DataSet)

2009-03-02 10:17 399 查看
使用存储过程返回一个数据集,SqlCommand -〉SqlDataAdapter -〉DataSet

SqlConnection userConnection = Connection.getConnection();
SqlCommand userCommand = new SqlCommand("storepname", userConnection);
userCommand.CommandType = CommandType.StoredProcedure;//采用存储过程
userCommand.Parameters.Add("@pa", SqlDbType.VarChar, 50);//存储过程参数
userCommand.Parameters["@pa"].Value = pa;//给参数赋值
userCommand.Connection.Open();
SqlDataAdapter adapter = new SqlDataAdapter(userCommand);
DataSet ds = new DataSet();
adapter.Fill(ds);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐