using System;
using System.Data;
using System.Data.SqlClient;public class gettingdata
{
public static void Main()
{
gettingdata mygettingdata = new gettingdata();
mygettingdata.Run();
} public void Run()
{
// Warning: Embedded usernames/passwords in database connection strings are inherently
// insecure, and should only be used on platforms (e.g. Win9x) that do not support Integrated
// Security. See the ASP.NET Quickstart for examples of Integrated Security.
SqlConnection myConnection = new SqlConnection("server=(local)\\NetSDK;uid=QSUser;pwd=QSPassword;database=northwind");
SqlDataAdapter mySqlDataAdapter = new SqlDataAdapter("select * from customers", myConnection); try
{
DataSet myDataSet = new DataSet(); mySqlDataAdapter.Fill(myDataSet,"Customers"); foreach (DataRow myDataRow in myDataSet.Tables["Customers"].Rows)
{
Console.WriteLine(myDataRow["CustomerId"].ToString());
}
}
catch(Exception e)
{
Console.WriteLine(e.ToString());
}
}
using System.Data;
using System.Data.SqlClient;public class gettingdata
{
public static void Main()
{
gettingdata mygettingdata = new gettingdata();
mygettingdata.Run();
} public void Run()
{
// Warning: Embedded usernames/passwords in database connection strings are inherently
// insecure, and should only be used on platforms (e.g. Win9x) that do not support Integrated
// Security. See the ASP.NET Quickstart for examples of Integrated Security.
SqlConnection myConnection = new SqlConnection("server=(local)\\NetSDK;uid=QSUser;pwd=QSPassword;database=northwind");
SqlDataAdapter mySqlDataAdapter = new SqlDataAdapter("select * from customers", myConnection); try
{
DataSet myDataSet = new DataSet(); mySqlDataAdapter.Fill(myDataSet,"Customers"); foreach (DataRow myDataRow in myDataSet.Tables["Customers"].Rows)
{
Console.WriteLine(myDataRow["CustomerId"].ToString());
}
}
catch(Exception e)
{
Console.WriteLine(e.ToString());
}
}
解决方案 »
- 像DBF VIEW,在批处理文件里,可以跟参数的软件如何开发?
- C#中String的解释
- WEBFORM:TreeView下选择节点得不到正确Text问题
- 关于web应用程序中如何使用scrollbar的问题,高手请进!
- 急!asp.net打印问题(进就给分)
- Dll复制本地和不复制本地有什么区别
- 请大家来评估一个技术方案设想
- combobox设置默认值,SelectedIndexChanged事件中有问题
- 主机名和域名一样??
- 为何只能更新一次,真奇怪
- .net B2版中的msdn有无中文内容啊?如果没有,现在市面上是否有关于.net的msdn啊?
- TABLE表不知建到什么地方去了,难道在内存中?
DataSet ds=new DataSet();
da.Fill(ds,"Employee");