asp.net三层架构增删改查

本文详细介绍了如何使用ASP.NET实现基于三层架构的数据库操作,包括链接数据库配置、Web.config设置、Model层定义、managementModel及managementDAL类的创建、DBHelper类的设计、BLL业务逻辑层的实现以及UI界面的基金类型.aspx页面和后台处理代码。通过这个实例,读者可以掌握ASP.NET中数据访问层和业务逻辑层的交互以及用户界面的处理方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

数据库

use master
if exists (select * from sysdatabases where name='bond')
drop database bond
create database bond
on PRIMARY
(
name='bond_data',
FILENAME='F:\asp\理财代销\management\bond.mdf',
filegrowth=20%,
size=10MB
)
LOG ON
(
name='bond_log',
FILENAME='F:\asp\理财代销\management\bond_log.ldf',
size=3MB,
MAXSIZE=20MB
)




use bond
--基金类型表(左用)
if exists (select * from sys.objects where name='jjlx')
drop table jjlx
create table jjlx
(
id int primary key identity(1,1),                     --id
jjlx varchar(50) not null                            --基金类型
)

--基金类型表增加存储过程
if exists(select * from sys.objects where name='jjlx_add')
drop procedure jjlx_add
go
create proc jjlx_add
@jjlx varchar(50) 
as
insert into jjlx values (@jjlx)
go
--基金类型表查询存储过程
if exists(select * from sys.objects where name='p_jjlx')
drop procedure p_jjlx
go
create proc p_jjlx
as
select * from jjlx
go
--基金类型表修改存储过程
if exists(select * from sys.objects where name='jjlx_gai')
drop procedure jjlx_gai
go
create proc jjlx_gai
@id int,
@jjlx varchar(50)
as
UPDATE jjlx SET jjlx=@jjlx where  id=@id 
go
--基金类型表删除存储过程
if exists(select * from sys.objects where name='jjlx_delete')
drop procedure jjlx_delete
go
create proc jjlx_delete
@id int,
@jjlx varchar(50)
as
delete from jjlx where id=@id and jjlx=@jjlx
go

链接数据库
Web.config

	<connectionStrings>
  <add name="conn" connectionString="server=.;database=bond;integrated security=true" />
 </connectionStrings>

Model层
managementModel类

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace managementModel
{
    public class jjlxs//基金类型表
    {
        public int id { set; get; }//id
        public string jjlx { set; get; } //基金类型

    }
}


DAL层
添加引用 Model层
添加程序集引用 using System.Configuration;
managementDAL类

 using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.SqlClient;
using System.Data;
using managementModel;
namespace managementDAL
{
    public class jjlxdal
    {
        DBHelper db
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值