using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Data.SqlClient;
namespace ConsoleApplication5 { class Program {
static void Main(string[] args)
{
String conString = "Data Source=.;Initial Catalog=dbone;Integrated Security=True";
SqlConnection conn = new SqlConnection(conString);
Console.WriteLine(conn);
Console.WriteLine("连接成功");
String sqlString = "select * from relation";
SqlCommand cmd = new SqlCommand(sqlString, conn);
conn.Open();
SqlDataReader reader = cmd.ExecuteReader();
// 拿到所有的数据
while(reader.Read()){
Console.WriteLine("qqnum:{0},passwd:{1}",reader["qqnum"],reader["passwd"]);
}
Console.WriteLine("ok确定下是否出错");
Console.ReadKey();
}
}
}