日期:2011-01-05 浏览次数:20413 次
一、数据库Test,
表:create table Customers
(
CustId int IDENTITY(1,1) primary key,
CustName varchar(20) not null,
Address varchar(50),
Linkman varchar(20)
)
//insert into Cusomers values('ggg','xuzhou','zhangsan');
二、配置文件web.config
<?xml version="1.0"?>
<configuration>
<appSettings/>
<connectionStrings>
<add name="TestConnectionString" connectionString="Data Source=GONGCHL;Initial Catalog=Test;Persist Security Info=True;User ID=sa;Password=123" providerName="System.Data.SqlClient"/>
</connectionStrings>
<system.web>
<compilation debug="true"/>
<authentication mode="Windows"/>
</system.web>
</configuration>
三、业务实体
using System;
using System.Collections.Generic;
using System.Text;
namespace com.Model
{
/// <summary>
/// 业务实体CustomerInfo
/// </summary>
[Serializable]
public class CustomerInfo
{
/// <summary>
/// 默认的构造函数
/// </summary>
public CustomerInfo() {}
/// <summary>
/// 有参数的构造函数
/// </summary>
/// <param name="custId">客户号</param>
/// <param name="custName">客户名称</param>
/// <param name="address">客户地址</param>
/// <param name="linkman">联系人</param>
public CustomerInfo(int custId, string custName, string address, string linkman)
{
this.custId = custId;
this.custName = custName;
this.address = address;
this.linkman = linkman;
}
private int custId;
public int CustId
{
get { return custId; }
set { custId = value; }
}
private string custName;
public string CustName
{
get { return custName; }
set { custName = value; }
}