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"
。
相关文档:
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) ......
下面是commond:
MySQLCommand cmd;
cmd = new MySQLDriverCS.MySQLCommand("DROP TABLE IF EXISTS test.mysqldrivercs_test",conn);
cmd.ExecuteNonQuery();
cmd.Dispose();
下面是insert:
string Value = "Value";
int SettingID = 1;
new MySQLInsertCommand(conn,
new object[,] {{"SettingID",SettingID},{"S ......
// 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 ......
媒体接入控制层的缩写
什么是mac!!!
如果你是通过校园网或小区接入Internet,那么一定听说过MAC地址。什么是MAC地址,MAC地址在这种局域网环境中究竟起到什么作用?下面就来介绍一下MAC地址的知识,MAC地址和IP地址的区别以及MAC地址在实际应用中所涉及到的安全问题。
一、基础知识
如今的网络是分层来实 ......