oledb 方式连接

 1   class Program
 2     {
 3         private static string constr = "server=.;database=northwnd;integrated security=sspi";
 4         static void Main(string[] args)
 5         {
 6             string source = "provider=sqloledb;" + constr;
 7             string select = "select contactname,companyname from customers";
 8             OleDbConnection con = new OleDbConnection(source);
 9             con.Open();
10             OleDbCommand cmd = new OleDbCommand(select, con);
11             OleDbDataReader reader = cmd.ExecuteReader();
12             while (reader.Read())
13                 Console.WriteLine("{0} from {1}", reader.GetString(0), reader.GetString(1));
14             reader.Close();
15             con.Close();
16         }
17 
18     }

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-02-18
  • 2021-12-15
  • 2022-03-04
猜你喜欢
  • 2022-12-23
  • 2021-06-09
  • 2022-12-23
  • 2021-07-05
  • 2022-02-09
  • 2021-07-30
相关资源
相似解决方案