易截截图软件、单文件、免安装、纯绿色、仅160KB

asp.net中读取Access连接字符串问题

我看到有两种方式:
第一种
  在web.config中添加:
  <connectionStrings>
  <add name="JiDiweb" connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|JiDiweb.mdb" />
  </connectionStrings>
  然后在DBHelper.cs类中读取
  string connectionString = ConfigurationManager.ConnectionStrings["JiDiweb"].ConnectionString;
第二种
  在web.config中添加:
  <appSettings>
  <add key="AccessConn" value="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="/>
  </appSettings>
  然后在DBHelper.cs类中读取
  string connectionString =ConfigurationManager.AppSettings["AccessConn"] + Server.MapPath("/App_Data/JiDiweb.db");
我看了这两种方法第二种呢,必须把dbhelper.cs类放在App_code文件夹中。否则会提示server.mappath没有应用命名空间。
现在我的项目是采用三层架构。我在DAL层中建了DBHelper类。并用了第一种连接方法,所以我想问下两种方法有什么区别吗?更IIS得虚拟目录搭上关系吗?忘高手提示下。谢谢!
 
建类库不会默认添加System.Configuration的引用


引用
建类库不会默认添加System.Web的引用

可以在添加引用后使用 System.Web.HttpContext.Current.Server.MapPath()找到


相关问答:

asp.net分页问题

select top 12 * from Product where [id] not in (select top 12 [id] from Product)
这样可以分页,但是我在后面想加个条件
select top 12 * from Product where [id] not in (select top 12 [id] from Prod ......

asp.net导出EXCEL问题! - .NET技术 / ASP.NET

C# code:

SqlConnection conn = CsDB.sqlcon();
SqlDataAdapter da = new SqlDataAdapter("select fwCoding from bjmuma_fwCoding where OrderNumber='" + Order + & ......

ASP.NET关于强制转换问题 - .NET技术 / ASP.NET

3个radioButton
 一个Button
一个label
C# code:

protected void Button1_Click(object sender, EventArgs e)
{
string str = null;
RadioButton rdo=(RadioButton)sender;
......

求助asp.net图片上传 - .NET技术 / ASP.NET

就是一个按钮,点击之后打开对话框,然后选取图片。就这样上传。。
怎么实现。在网上搜到那么多的代码,全是很多的那种,不知道,看不下去。
所以在这里想请大哥大姐帮帮忙。

使用自带的fileupload控件可以实现 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号