asp.net里面如何用三层架构调用存储过程呢?

来源:百度知道 编辑:UC知道 时间:2024/05/21 19:07:12
初次在这里面用不知道啊,请各位大侠帮忙
我想要在业务层和数据访问层里的函数具体都是怎样的?

逻辑层只要把参数传到数据层就可以了,在数据层里进行数据库操作
表示层:
MethedBLL bLL=new MethedBLL();
bLL.Methed(参数1,参数2);
逻辑层
public 返回类型 Methed(string 参数1,string 参数2)
{
MEthedDAL dAL=new MethedDAL();
dAL.Methed(参数1,参数2);
}
数据访问层
public 返回类型 Methed(string 参数1,string 参数2)
{
sqlconnection con=new sqlconnection(连接字符串);
sqlcommand cmd=new sqlcommand();
cmd.connection=con;
cmd.commandtext="存储过程名称";
cmd.commandtype=commandtype.procedure;
cmd.parameters.add(添加参数);
cmd.parameter["参数名"].value=参数1;
...
con.open();
cmd.executenonquery();
con.close();

}

平时
dim strsql as string="select * from 表"
现在
无参数
dim strsql as string="execute 存储过程名 "
有参数
dim strsql as string="execute 存储过程名 参数1.参数2 "
其他操作一样

下一个CodePlus的软件,把数据库弄好,然后用这个软件和数据库中的表可生成底层代码,copy到DAL层和Model层,修改一下里面的代码,存储过程应该是在DAL层中调用的吧。我同学这么教我的,具体我也没去实现过,恩,等下