与程序的数据库连接. [英] Database connectivity with the program.
本文介绍了与程序的数据库连接.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何将ASP.NET网页与Microsoft Access数据库连接?有人请帮帮我.
How do I connect my ASP.NET Web Page with the Microsoft Access Database? Someone please help me out.
推荐答案
简短答案:使用ADO.NET:
http://en.wikipedia.org/wiki/ADO.NET [ http://msdn.microsoft.com/en-us/library/aa286484.aspx [ ^ ].
对于初学者来说,我发现此CodeProject文章最有用:
为初学者使用ADO.NET [
Short answer: use ADO.NET:
http://en.wikipedia.org/wiki/ADO.NET[^],
http://msdn.microsoft.com/en-us/library/aa286484.aspx[^].
For a beginner, I find this CodeProject article most useful:
Using ADO.NET for beginners[^].
Good luck,
—SA
以下代码将在您的web.config
中
The code below will be in your web.config
<connectionstrings>
<add name="ConnectionStringName" connectionstring="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|DatabaseName.mdb;Persist Security Info=True" providername="System.Data.OleDb" />
</connectionstrings>
现在下面是在页面后面的类或代码中使用ConnectionString名称的方式
//数据库连接方法
Now below this is how you will use your ConnectionString name in your class or code behind a page
//Method for A Database Connection
public string dbConnection()
{
string connString = ConfigurationManager.ConnectionStrings["ConnectionStringName"].ConnectionString;
try
{
// set up and open connection
dbConn = new OleDbConnection(connString);
dbConn.Open();
}
catch (OleDbException exp)
{
}
return connString;
}
也许您将需要以下名称空间
使用System.Configuration;
希望对您有帮助...
祝你好运
快乐编码:)
maybe u will need the following namespace
using System.Configuration;
Hope it helps...
Best Luck
Happy Coding :)
这将为您提供有关所有基本数据访问操作的完整教程
了解ADO.NET的初学者教程 [ ^ ]
This will give you a complete tutorial on all basic data access operations
A Beginner''s Tutorial for Understanding ADO.NET[^]
这篇关于与程序的数据库连接.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文