c# 中dataset的使用
来源:互联网 发布:天津广电网络营业厅 编辑:程序博客网 时间:2024/06/07 16:54
查询数据的源代码:
string conString="data source=127.0.0.1;database=test;user id=sa;password=123";string strSQL="select * from student";SqlConnection myConnection=new SqlConnection(conString);DataSet ds=new DataSet();myConnection.Open();SqlDataAdapter adapter=new SqlDataAdapter(strSQL,myConnection);adapter.Fill(ds,"ds");myconnection.Close();
封装后的代码是:
public static DataSet Query(string StrSql) { using (SqlConnection connection = new SqlConnection(myConStr)) { DataSet ds = new DataSet(); connection.Open(); SqlDataAdapter command = new SqlDataAdapter(StrSql,connection); command.Fill(ds,"ds"); return ds; } }
使用的方法:
private void button2_Click(object sender, EventArgs e) { string StrQuery = "select * from student"; DataSet ds = OperateDatabase.Query(StrQuery); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { string j = ds.Tables[0].Rows[i][0].ToString(); MessageBox.Show(j); } }
- c# 中dataset的使用
- c#中DataSet的使用
- C#中DataSet类的使用
- C# 中DataSet类的使用
- C#中DataSet类的使用
- C# DataSet的使用
- C# DataSet 的使用
- C#中DataSet的用法
- C#中DataSet的使用方法
- c#中Dataset的用法
- C#中DataSet、SqlDataAdapter的使用-关于数据库操作
- c#中,对DataSet、DataTable的操作
- C#中DataSet和DataReader的区别
- C#中DataSet和DataReader的区别
- C#中DataSet和DataReader的区别
- C#中DataSet和SqlDataReader的区别
- C# 中DataSet、DataAdapter的用法
- C#中DataSet和DataReader的区别
- 1337 微软( ⊙ o ⊙ )啊!
- Mono归来,Xamarin公司获取Mono及其相关产品知识产权权利
- 如何批量的更替数据库里的东西
- 8. A candle lights others and consumes itself. 蜡烛照亮了别人,却毁灭了自己
- 利用log4j的JDBCAppender把日志写入数据库中
- c# 中dataset的使用
- RMQ (Range Minimum/Maximum Query)算法
- .NET开源项目介绍 - ClosedXML - 生成Excel文件
- ListView控件的使用
- linux内存管理
- JVM creation failed
- java多线程学习1
- 06-struts-动态ActionForm
- 对于custom.pll二次开发的一些建议