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);
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);
相关文章推荐
- c#使用存储过程返回数据集(SqlCommand->DataSet)
- c#使用存储过程返回数据集(SqlCommand->DataSet)
- 将存储过程返回的数据集填充到DataSet/DataTable(C#)
- C# 远程传输数据集(DataSet ->二進制)(zhuan)
- C#读取数据库返回泛型集合 把DataSet类型转换为List<T>泛型集合
- C#中的类SqlCommand对象使用方法ExecuteNonQuery()调用SQLServer存储过程时,存储过程执行成功,数据发生改变,但是返回-1
- C#读取数据库返回泛型集合 把DataSet类型转换为List<T>泛型集合
- C#使用集合组织数据(HashTable、ArrayList、List<T>,Dictionary<K,V>
- C#使用比较操作符(!=、<、>、<=、>=)的字符串构造Lambda表达式树,并生成委托执行
- <Unity UGUI>使用c#反射实现UGUI文本显示的国际化
- hibernate下使用getHibernateTemplate 返回List<Map>
- 使用存储过程返回一个数据集
- C# Tuple<T1,T2....T>元组的使用
- [C#基础教程]C#泛型集合—Dictionary<K,V>使用技巧
- C#中的匿名函数使用,类名<T>
- ADO.NET 更新数据库的2种方式::(1)使用DataSet对象更新数据集;(2)使用SqlCommand对象更新单条记录
- C# 新委托使用方法 Lambda表达式,运算符 =>
- 《Effective C#》读书笔记——条目26:避免返回对内部类对象的引用<使用C#表达设计>
- C#中Queue<T>类的使用以及部分方法的源码分析
- C#List<Category>使用方法