有最新版的IBastis.Net的源代码等,还有NPetShop的例子(例子比较老)
将NPetShop的例子下载好之后,由于原来是基于VS2003的版本,在本地用VS2005打开后编译、运行时有一些问题,主要问题和解决方法如下:
1、转换成VS2005的版本
a、直接打开NPetshop.sln文件,按提示一直点击"下一步"进行转换
b、转换后不能找到web项目,把原来的web项目删除,然后通过添加现有网站的方式加入NPetshop.Web
2、修改配置文件
最简单的方式是直接修改NPetshop.Web目录下的dao.config,如下一条语句:
<
dataSource name
=
"
Access
"
connectionString
=
"
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=F:\Study\_Net\框架\iBATIS.NET\NPetshop\NPetshop.Web\npetshop.mdb
"
/>
将其中的路径改成你自己的路径。
PS:npetshop.mdb是一个access文件,在NPetshop.Web目录下
3、编译时报错:不允许循环文件引用
由于VS2005和VS2003有一定的区别导致,找到文件:NPetshop.Web\UserControls\Catalog\SearchProduct.ascx
将如下代码:
<%
@ Register TagPrefix
=
"
uc1
"
TagName
=
"
TopBar
"
Src
=
"
../TopBar.ascx
"
%>
<% @ Register TagPrefix = " uc1 " TagName = " Banner " Src = " ../Banner.ascx " %>
<% @ Register TagPrefix = " cc1 " Namespace = " NPetshop.Presentation.Controls " Assembly = " NPetshop.Presentation " %>
< uc1:Banner id = " Banner " runat = " server " ></ uc1:Banner >
< uc1:TopBar id = " TopBar " runat = " server " ></ uc1:TopBar >
修改成:
<% @ Register TagPrefix = " uc1 " TagName = " Banner " Src = " ../Banner.ascx " %>
<% @ Register TagPrefix = " cc1 " Namespace = " NPetshop.Presentation.Controls " Assembly = " NPetshop.Presentation " %>
< uc1:Banner id = " Banner " runat = " server " ></ uc1:Banner >
< uc1:TopBar id = " TopBar " runat = " server " ></ uc1:TopBar >
<%
@ Register TagPrefix
=
"
uc1
"
TagName
=
"
TopBar
"
Src
=
"
../TopBar.ascx
"
%>
<% @ Register TagPrefix = " uc2 " TagName = " Banner " Src = " ../Banner.ascx " %>
<% @ Register TagPrefix = " cc1 " Namespace = " NPetshop.Presentation.Controls " Assembly = " NPetshop.Presentation " %>
< uc2:Banner id = " Banner " runat = " server " ></ uc2:Banner >
< uc1:TopBar id = " TopBar " runat = " server " ></ uc1:TopBar >
主要就是不能出现相同的uc1
<% @ Register TagPrefix = " uc2 " TagName = " Banner " Src = " ../Banner.ascx " %>
<% @ Register TagPrefix = " cc1 " Namespace = " NPetshop.Presentation.Controls " Assembly = " NPetshop.Presentation " %>
< uc2:Banner id = " Banner " runat = " server " ></ uc2:Banner >
< uc1:TopBar id = " TopBar " runat = " server " ></ uc1:TopBar >
4、运行时报错
按如上操作后,应该就可以进入首页了,但是运行时可能报系统错误,通过单步调试,发现需要手工给
NPetShop.Web项目添加引用,引用位置:NPetshop\External-bin\ByteFX.MySqlClient.dll
这样,NPetShop的例子应该就可以正常运行了