易截截图软件、单文件、免安装、纯绿色、仅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 ......

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


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

Access 分页查询

   自己做的一个.net错误收集,收集整站的500错误,用的access数据库。数据过20000后,使用传统的SELECT TOP 10 * from TABLE WHERE ID NOT IN(SELECT TOP 10*10 * from TABLE)查询竟然要好几分钟,汗~~~~!
   网上查到的一条语句还不错。
    SELECT TOP 10 id,Message,CreateTime ......

ADOX创建Access用户和组

// BeginGroupCpp.cpp
// compile with: /EHsc
#import "msadox.dll" no_namespace
#include "iostream"
using namespace std;
inline void TESTHR(HRESULT x) {if FAILED(x) _com_issue_error(x);};
int main() {
   if (FAILED(::CoInitialize(NULL)) )
      return -1;
&n ......

VS2005中,access对只读目录的属性判断不准确

只读目录,
C:\>attrib +A +S +H +R testdir
C:\>attrib testdir
A  SHR     C:\testdir
(1)VC6.0的执行结果:
***********test stat***********************
file [c:\testdir] exists!
file [c:\testdir] is directory!
file [c:\testdir] can be read!
file [c:\testdir] can n ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号