三层架构。。。
那位帮我把下面的用三层架构写下。。。sqlcon = new SqlConnection(strCon);
sqlcon.Open();
string sqlstr = "select name as 员工姓名,易做图 as 性别,nPlace as 籍贯,date as 注册日期,money as 工资,photo from tb_Member";
SqlDataAdapter myda = new SqlDataAdapter(sqlstr, sqlcon);
DataSet myds = new DataSet();
myda.Fill(myds, "tb_Member");
DataRowView mydrv = myds.Tables["tb_Member"].DefaultView[0];
GridView1.DataSource = myds;
GridView1.DataBind(); --------------------编程问答-------------------- ???
--------------------编程问答-------------------- 不知所云
View(.aspx)--------->BILL(业务处理)------>DAL(数据处理)---->永久存储(数据库)
DALFactory(工厂)、IDL(接口)、Model来直接或间接的联系他们之间的关系
--------------------编程问答-------------------- 先分层,数据层调用储存过程,业务层调用数据层,用户层调用业务层的方法。 --------------------编程问答-------------------- 得先写个储存过程呀 --------------------编程问答-------------------- DAL
using System;
using System.Data;
using System.Text;
using System.Data.SqlClient;
using GZWeb.IDAL;
namespace yournamespace.SQLServerDAL
{
public class tb_Member:Itb_Member
{
public DataSet GetDataSet()
{
string strSql="select name as 员工姓名,易做图 as 性别,nPlace as 籍贯,date as 注册日期,money as 工资,photo from tb_Member";
return DbHelper.ExecuteDataSet(strSql.ToString());//取DataSet函数
}
}
}
-----------------------
IDAL
using System;
using System.Data;
namespace yournamespace.IDAL
{
public inte易做图ce Itb_Member
{
DataSet GetDataSet();
}
}
--------------------
using System;
using System.Reflection;
using System.Configuration;
using GZWeb.IDAL;
namespace yournamespace.DALFactory
{
private static readonly string path = System.Configuration.ConfigurationSettings.AppSettings["DAL"];
public sealed class DataAccess
{
private static readonly string path = System.Configuration.ConfigurationSettings.AppSettings["DAL"];
public static ERP.IDAL.IAccount Createtb_Member()
{
string className = path + ".Createtb_Member";
return (yournamespace.IDAL.ICreatetb_Member)Assembly.Load(path).CreateInstance(className);
}
}
}
----------------------
BILL
using System;
using System.Data;
using System.Text;
using System.Data.SqlClient;
using GZWeb.IDAL;
using GZWeb.DALFactory;
namespace yournamespace.BLL
{
public class tb_Member
{
private static readonly Itb_Member dal = DataAccess.Createtb_Member();
public DataSet GetDataSet()
{
return dal.GetDataSet();
}
}
}
}
--------------------编程问答-------------------- 忘了改GZWeb为yournamespace
--------------------编程问答-------------------- 为你的GridView配置数据源,使用sqlDataSource或者objectDataSource控件,这是非常好的、贴切地三层设计的入手方法。
补充:.NET技术 , ASP.NET