教程集 www.jiaochengji.com
教程集 >  脚本编程  >  Asp.net  >  正文 asp.net怎么连接access数据库

asp.net怎么连接access数据库

发布时间:2016-07-29   编辑:jiaochengji.com
asp.net程序中如何连接access数据库?分享一例代码,学习下asp.net连接access数据库的方法,有需要的朋友做个参考。

例子,asp.net连接access数据库。
文件:index.aspx
 

复制代码 代码示例:
<%@ page language="c#" %>
<%@ import namespace="system.data" %>
<%@ import namespace="system.data.oledb" %>
<script runat="server">
// insert page code here
//
void page_load(){
string db=@"database/data.mdb";
string connstr="provider=microsoft.jet.oledb.4.0;data source="+server.mappath(db)+";";
string sqlcmd="create table ieb_webs(id identity primary key,title varchar(255) default null)";
oledbconnection conn=new oledbconnection(connstr);
conn.open();
oledbcommand olecmd=new oledbcommand(sqlcmd,conn);
olecmd.executenonquery();  //执行sql命令
response.write("数据表建立完成!");
}
conn.close();
conn=null;
olecmd=null;
}
</script>
<html>
<head>
</head>
<body>
<form method="post" runat="server">
<!-- insert content here -->
</form>
</body>
</html>

在asp.net中连接access数据库,需要microsoft.jet.oledb.4.0驱动,一般默认都有安装。

您可能感兴趣的文章:
asp.net怎么连接access数据库
php怎么连接access数据库
asp 连接access数据库二种方法
在C#.net 中读取EXCEL文件的数据
asp access入门级数据库连接文件
asp.net 3.5中在web.config文件创建ACCESS连接字符串的方法
jsp怎么连接access数据库
php连接access数据库的三种方法
c#使用config文件连接access数据库
ASP.NET 数据库连接方式

关键词: access数据库   
[关闭]
~ ~