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

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"



相关文档:

C# ASP.NET 获取脚本语句并用文本的方式显示出来

protected void Button6_Click(object sender, EventArgs e)
    {
        this.Label11.Text = HtmlEncode(this.TextBox3.Text);
 
       
    }
    protected static string HtmlEn ......

access 分页用 SQL查询语句

select top 每页显示的记录数 * from topic where id not in (select top (当前的页数-1)×每页显示的记录数 id from topic order by id desc) order by id desc
select top 每页显示的记录数 * from topic where id not in (select top (当前的页数-1)×每页显示的记录数 id from topic order by id desc) ......

VB/C++/C#串口通讯源代码【附详细注释】


VB
    If MSComm1.PortOpen = True Then MSComm1.PortOpen = False
    MSComm1.CommPort = i1
    MSComm1.PortOpen = True
    MSComm1.InputMode = comInputModeBinary
    MSComm1.InBufferCount = 0
& ......

用VFP列出ACCESS所有表的字段结构,含标题。

     set safety off
     local oo,lcStr,lcMdbFile,i,x,lnFields,lcTableName,lnFieldtype,lcCurdir
     lcCurdir = sys(5) + curdir()
     lcNowdir = getdir()
     cd (lcNowdir)
   &nb ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号