如何将Microsoft Access用作ASP.NET网站中的数据库?可能吗?

最佳答案

是的,有可能。您将必须使用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等

10-04 18:16