Jasmine Appelblad Jasmine Appelblad - 2 months ago 24
ASP.NET (C#) Question

CRUD with Access Database using ASP.NET

How can I use Microsoft Access as a database in ASP.NET website? Is it possible?

Answer

Yes it possible. You will have to use OLEDB to Access the MS Access Database.

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()

Taken from: http://www.beansoftware.com/ASP.NET-Tutorials/Connecting-Access-Sql-Server.aspx

It would be the same as SQL Server but you will be using OleDbConnection, OleDbCommand etc