namespace DALFactory
{
public sealed class DataAccess
{
private static string path = "accessDAL";
public static object CreateObject(string className)
{
string classname = path + "." + className;
return Assembly.Load(path).CreateInstance(classname);
}
}
3.实现类accessDAL的代码:using System;
using System.Collections.Generic;
using System.Data.OleDb;
namespace accessDAL
{
public class ABook:IDAL.IBook
{
private static string conn = "Provider=Microsoft.Jet.OleDb.4.0;Data Source='I:/软件工程/book.mdb'";
public Model.Book getBook(string b_name)
{
string sqlstring = "select * from book where b_name like " + "'%" + b_name + "%'";
OleDbConnection ole = new OleDbConnection(conn);
OleDbCommand dbc = new OleDbCommand(sqlstring, ole);
ole.Open();
OleDbDataReader p = dbc.ExecuteReader();
if (p.Read() == true)