如何在ASP.NET网站中将Microsoft Access用作数据库?可能吗?
答案 0 :(得分:3)
当然,Access有一个oledb connection
现在我不推荐它,除非它是一个玩具应用程序。但是可以做到。
答案 1 :(得分:3)
是的,有可能。
查看本教程。
此处不再在线:
http://www.aspfree.com/c/a/Microsoft-Access/Connecting-to-a-Microsoft-Access-database-with-ASPNET/
答案 2 :(得分:3)
是的可能。您必须使用OLEDB来访问MS Access数据库。
Dim con As New System.Data.OleDb.OleDbConnection
Dim myPath As String
myPath = Server.MapPath("Database1.mdb")
con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Data source=" & myPath & ";"
Dim myCommand As New System.Data.OleDb.OleDbCommand
myCommand.CommandText = "insert into Students(Firstname,Lastname,Address) values('" & txtFirstname.Text & "','" & txtLastname.Text & "','" & txtAddress.Text & "')"
myCommand.Connection = con
con.Open()
myCommand.ExecuteNonQuery()
con.Close()
取自:http://www.beansoftware.com/ASP.NET-Tutorials/Connecting-Access-Sql-Server.aspx
它与SQL Server相同,但您将使用OleDbConnection,OleDbCommand等
答案 3 :(得分:2)
是的,这是可能的,但不建议!
Access从未打算用于像Web这样的高度并发环境。 我不知道你想要创建什么类型的网站,但你做得更好 使用像SQL Express (Free download on Microsoft)
这样的真实数据库答案 4 :(得分:0)
string strConn ="PROVIDER=Microsoft.Jet.OLEDB.4.0; Data Source=|DataDirectory|referendum-abrogrativo.mdb";
OleDbConnection conn = new OleDbConnection(strConn);
try
{
conn.Open();
string query = "SELECT * FROM User WHERE Email = '" + email + "' AND Password = '" + password + "'";
OleDbCommand cmdE = new OleDbCommand();
cmdE.Connection = conn;
cmdE.CommandText = query;
OleDbDataReader dr;
dr = cmdE.ExecuteReader();
if (dr.Read())
{
_IDUte = dr.GetValue(0).ToString();
_Email = dr.GetValue(3).ToString();
_Password = dr.GetValue(4).ToString();
}
else
{
_Email = "";
_Password = "";
}
dr.Close();
conn.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
conn.Close();
}