vs2005中的强类型dataset
vs2005中的新的dataset,与2003中有着不同,创建 Typed dataset后,系统自动加入了TableAdpter,根据提供的这个TableAdapter,就可以很方便的写出DataAccess Layer Code,DataAccess Layer的编写更加简便,以下是一个简单的示例。
using System;
using System.Collections.Generic;
using System.Text;
namespace DatasetTest
{
public class TestDataAccess:IDisposable
{
private dsNorthwindTableAdapters.CustomersTableAdapter dsc = new DatasetTest.dsNorthwindTableAdapters.CustomersTableAdapter();
public dsNorthwind.CustomersRow RetiereCustomersRow(string customersid)
{
//dsNorthwindTableAdapters.CustomersTableAdapter ct = new DatasetTest.dsNorthwindTableAdapters.CustomersTableAdapter();
dsNorthwind.CustomersRow dcr = dsc.GetDataByCustomerID(customersid)[0];
return dcr;
}
public dsNorthwind.CustomersDataTable RetiereCustmoers()
{
//dsNorthwindTableAdapters.CustomersTableAdapter ct = new DatasetTest.dsNorthwindTableAdapters.CustomersTableAdapter();
return dsc.GetData();
}
public void UpdateCustomers(dsNorthwind.CustomersRow CustomersRow)
{
dsc.Update(CustomersRow);
}
IDisposable 成员
}
}


浙公网安备 33010602011771号