using System; using System.Data; using System.Data.SqlClient;
///<summary> /// Demonstrates how to work with SqlConnection objects ///</summary> class SqlConnectionDemo { staticvoid Main() { // 1. Instantiate the connection实例化连接 SqlConnection conn = new SqlConnection( "Data Source=(local);Initial Catalog=Northwind;Integrated Security=SSPI");
SqlDataReader rdr = null; try { // 2. Open the connection打开连接 conn.Open(); // 3. Pass the connection to a command object