会员
周边
众包
新闻
博问
闪存
所有博客
当前博客
我的博客
我的园子
账号设置
简洁模式
...
退出登录
注册
登录
alonestarsz
博客园
首页
新随笔
联系
订阅
管理
公告
在CS程序中访问Access
private
void
CallAccess()
{
string
OLEDBConnStr
=
"
Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};
"
;
string
resourcePath
=
filePath(
"
100keypolluters.mdb
"
);
OLEDBConnStr
=
string
.Format(OLEDBConnStr,resourcePath);
string
strCreateTableSQL
=
"
select count(*) from enterprises_05
"
;
OleDbConnection oConn
=
new
OleDbConnection();
oConn.ConnectionString
=
OLEDBConnStr;
OleDbCommand oCreateComm
=
new
OleDbCommand();
oCreateComm.Connection
=
oConn;
oCreateComm.CommandText
=
strCreateTableSQL;
oConn.Open();
object
count
=
oCreateComm.ExecuteScalar();
oConn.Close();
}
private
string
filePath(
string
fileName)
{
string
resourcePath
=
Application.StartupPath;
resourcePath
=
resourcePath.Replace(
@"
bin\Debug
"
,
@"
resource\
"
);
resourcePath
+=
fileName;
return
resourcePath;
}
posted on
2005-11-16 14:54
天煞孤星
阅读(
108
) 评论(
0
)
编辑
收藏
举报
会员力量,点亮园子希望
刷新页面
返回顶部
Powered by:
博客园
Copyright © 2024 天煞孤星
Powered by .NET 8.0 on Kubernetes