program.cs

来自「C#高级编程第6版随书源代码 值得下载」· CS 代码 · 共 32 行

CS
32
字号
using System;
using System.Data;
using System.Data.SqlClient;

namespace ClientApp
{
   class Program
   {
      static void Main()
      {
         string connectionString =
             @"server=(local);database=AdventureWorks;trusted_connection=true";
         SqlConnection connection = new SqlConnection(connectionString);
         SqlCommand command = connection.CreateCommand();
         command.CommandText = "GetCustomerOrdersCLR";
         command.CommandType = CommandType.StoredProcedure;
         SqlParameter param = new SqlParameter("@customerId", 3);
         command.Parameters.Add(param);
         connection.Open();
         SqlDataReader reader =
               command.ExecuteReader(CommandBehavior.CloseConnection);
         while (reader.Read())
         {
            Console.WriteLine("{0} {1:d}", reader["SalesOrderID"],
               reader["OrderDate"]);
         }
         reader.Close();

      }
   }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?