关于ACCESS数据库连接字符串的问题 我用的是ACCESS数据库怎么实现 向 ASP那样把数据库连接字符串放到一个文件里面当我需要的时候 只要<!-- #include file="conn.asp"-->就可以了~在。NET里面 如何实现 谢谢、 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 应该怎么写呀!~SQL 我会 但是 ACCESS 就不行呀!~高手指教 发个代码行么???谢谢 "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA Source="+System.Web.HttpContext.Current.Server.MapPath("db1.mdb"); 在.net 里对应的做法是建立一个类来代替 <!-- #include file="conn.asp"--> 在WEB.CONFIG中加入<appSettings> <add key="strDBAccess" value="provider=microsoft.jet.oledb.4.0;data source=d:\AspxNet_2004.mdb"></add></appSettings>在后台调用时:strDB=ConfigurationSettings.AppSettings("strDBAccess") 在web.config<configuration> <appSettings> <add key="ConnectString" value="Data Source={0};Password=;Provider=Microsoft.Jet.OLEDB.4.0" /> <add key="DbPath" value="DataBase\Hover.mdb" /><!--物理路径--> </appSettings>Globals.cs private static string Constring; /// <summary> /// 数据连接字符串 /// </summary> public static string ConnectString { get { if(Constring==null) { Constring=string.Format(System.Configuration.ConfigurationSettings.AppSettings["ConnectString"], System.Web.HttpContext.Current.Request.PhysicalApplicationPath+(System.Configuration.ConfigurationSettings.AppSettings["DbPath"])); return Constring; } else { return Constring; } } }调 用数据连接字符串时OleDbConnection OleCon=new OleDbConnection(项目名.Globals.ConnectString );这样调 用的是物理路径,不管在哪调 用都不会有相对路径和绝对路径的问题 。 回复人: pingnt(努力工作为明天) ( ) 信誉:99 我也试过可惜只能用绝对路径回复人: zytp(翱翔.Net) ( ) 信誉:94 很好 但是是 C# 的有人能给个VB。NET的么 ???谢谢了 asp.net判断IP网段 所谓的表的关联 配置 运行asp.net网站的服务器 DataSet怎样用while循环输出? 请教gridview如何调用XML 如何获取本页的Html代码? 求助!!后台取得前台的值 请问如何改变datalist中table里的某一行的样式 关于.net的托管 ASP.NET安装问题 在文件上传的浏览中,如何限制文件上传的类型呢?比如只上传pdf,doc,xls文件,哪位给一段示例,谢谢!!! 如何在Datagrid 中进行删除提示(第一个解决者得全分)
<appSettings>
<add key="strDBAccess" value="provider=microsoft.jet.oledb.4.0;data source=d:\AspxNet_2004.mdb"></add>
</appSettings>在后台调用时:
strDB=ConfigurationSettings.AppSettings("strDBAccess")
<configuration>
<appSettings>
<add key="ConnectString" value="Data Source={0};Password=;Provider=Microsoft.Jet.OLEDB.4.0" />
<add key="DbPath" value="DataBase\Hover.mdb" /><!--物理路径--> </appSettings>Globals.cs private static string Constring;
/// <summary>
/// 数据连接字符串
/// </summary>
public static string ConnectString
{
get
{
if(Constring==null)
{
Constring=string.Format(System.Configuration.ConfigurationSettings.AppSettings["ConnectString"],
System.Web.HttpContext.Current.Request.PhysicalApplicationPath+(System.Configuration.ConfigurationSettings.AppSettings["DbPath"]));
return Constring; }
else
{
return Constring;
}
}
}
调 用数据连接字符串时
OleDbConnection OleCon=new OleDbConnection(项目名.Globals.ConnectString );
这样调 用的是物理路径,不管在哪调 用
都不会有相对路径和绝对路径的问题 。