WEB开发网
开发学院数据库MSSQL Server 教你如何来进行编写通用的数据访问 阅读

教你如何来进行编写通用的数据访问

 2007-05-19 09:42:08 来源:WEB开发网   
核心提示: 从 Microsoft® Access 进行数据检索的代码类似于如下所示:using System;using System.Data;using System.Data.Common;using System.Data.OleDb;using System.Configurati

从 Microsoft® Access 进行数据检索的代码类似于如下所示:

using System;
using System.Data;
using System.Data.Common;
using System.Data.OleDb; 
using System.Configuration;  
using Common;
namespace DAL
{
  public class CustomersData : IDbCustomers
  {
   public DataTable GetCustomers()
   {
     string ConnectionString =
      ConfigurationSettings.AppSettings
      ["ConnectionString"];
     using (OleDbConnection cnn = new OleDbConnection
         (ConnectionString))
     {
      string cmdString = "SELECT CustomerID," +
        "CompanyName,ContactName " +
        "FROM Customers";
      OleDbCommand cmd =
        new OleDbCommand (cmdString, cnn);
      OleDbDataAdapter da = new
        OleDbDataAdapter(cmd);
      DataTable dt = new DataTable("Customers");
      da.Fill(dt);
      return dt;
     }
   }
   public DataTable GetCustomerOrders(string CustomerID)
   {
     // 待定
     return null;
   }
   public DataTable GetCustomersByCountry
     (string CountryCode)
   {
     // 待定
     return null;
   }
   public bool InsertCustomer()
   {
     // 待定
     return false;
   }
  }
}

上一页  3 4 5 6 7 8 9 10  下一页

Tags:如何 进行 编写

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接