Access数据库在C#.net下的存储路径问题
即使我将数据库放在项目内建的文件夹db下,可是进行存储操作的时候,数据表没有任何变化。后来发现储存改变发生在bin\\debug\\db目录下的数据库中,这个数据库是在程序运行时自动复制过去的,可是为什么存储变化没有反应到外面项目内的数据库db下呢?我想连接字符串中datasource中的datadirectory存在一些玄机,于是我找到一个改变存储路径的方法,以实现对数据库操作能落实到你指定的项目数据库文件中。
//改变数据库存储路径
string p = AppDomain.CurrentDomain.BaseDirectory;//获取操作的直接路径
//重新定位数据库
if (p.IndexOf("\\bin\\") > 0)
{
if (p.EndsWith("\\bin\\Debug\\"))
p = p.Replace("\\bin\\Debug", "");
if (p.EndsWith("\\bin\\Release\\"))
p = p.Replace("\\bin\\Release", "");
}
if (!p.EndsWith("App_Data\\"))
p = p + "db\\";
p = p + "App_Data\\";//这里可以指定项目数据库文件夹名
AppDomain.CurrentDomain.SetData("DataDirectory", p);
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
其实最后bin\\debug\\db下还是会有一份数据库文件,但是进行的操作可以落实反应到外面项目里数据库文件了。App.config文件里的连接字符串为:connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|数据库名.mdb"
。
相关文档:
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using  ......
protected void Button6_Click(object sender, EventArgs e)
{
this.Label11.Text = HtmlEncode(this.TextBox3.Text);
}
protected static string HtmlEn ......
http://ayic1.blog.163.com/blog/static/27343030200965103528805/
静态变量
当我们编写一个类时,其实就是在描述其对象的属性和行为,而并没有产生实质上的对象,只有通过new关键字才会产生出对象,这时系统才会分配内存空间给对象,其方法才可以供外部调用。
& ......
我的系统是ubuntu6.06,最近新装好的mysql在进入mysql工具时,总是有错误提示:
# mysql -uroot -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
使用网上介绍的方法修改root用户的密码:
# mysqladmin -uroot -p password 'newpassword'
Enter password:
m ......
set safety off
local oo,lcStr,lcMdbFile,i,x,lnFields,lcTableName,lnFieldtype,lcCurdir
lcCurdir = sys(5) + curdir()
lcNowdir = getdir()
cd (lcNowdir)
&nb ......