本文共 673 字,大约阅读时间需要 2 分钟。
using System;
using System.Threading; using System.Threading.Tasks; using System.Data; using System.Data.SqlClient;namespace ThreadTest
{ class Program { static void Main() { //A a1 = new A(); //a1.Method(); //int a = 15, b = 10; //float c = a / b; //Console.WriteLine(c); //Console.ReadKey(); SqlConnection con = new SqlConnection(); con.ConnectionString = "server = XXX;XXX;integrated security=SSPI"; con.Open(); String sql = "select * from person"; // 查询语句SqlDataAdapter myda = new SqlDataAdapter(sql, con); // 实例化适配器
DataTable dt = new DataTable(); // 实例化数据表
myda.Fill(dt); // 保存数据 var a = dt.Rows[0]["name"].ToString(); Console.WriteLine(a); Console.ReadKey(); }}
}
转载地址:http://cpxlf.baihongyu.com/