Denisdh
asked on
How to access MS Access Database in C#/ASP.Net
I need to access a table in a *.mdb file in a aspx/C# web service and make some calculations and then display it. I'm looking for a tutorial but haven't found anything online.
this is password protected ms access DB
Dim cn As New OleDbConnection
("Provider=Microsoft.Jet.O LEDB.4.0;D ata
Source=c:\AccessDB\MyDBwit hPwd.mdb;U ser Id=admin;Jet
OLEDB:Database Password=admin")
Dim cn As New OleDbConnection
("Provider=Microsoft.Jet.O
Source=c:\AccessDB\MyDBwit
OLEDB:Database Password=admin")
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
That code is VB. Is it much different in C#?
ASKER
Thanks for the pointers guys. Ignore the last comment I only saw the first post when I wrote it. I'll head off and do some learning!
ASKER
<asp:AccessDataSource ID="AccessDataSource1" runat="server"
DataFile="~/App_Data/repor ts.mdb"
SelectCommand="SELECT [Agent], [County] FROM [tblWebData]"></asp:Access DataSource >
asp:AccessDataSource can be found in the toolbox of VWD and it works fine.
DataFile="~/App_Data/repor
SelectCommand="SELECT [Agent], [County] FROM [tblWebData]"></asp:Access
asp:AccessDataSource can be found in the toolbox of VWD and it works fine.
importing the namespace System.Data.Odbc
example for grid binding
Dim cn As New OdbcConnection("Driver={Mi
Driver (*.mdb)};DBQ=c:\AccessDB\M
Dim da As New OdbcDataAdapter("select * from emp", cn)
Dim dt As New DataTable
da.Fill(dt)
da.Dispose()
cn.Dispose()
Me.DataGrid1.DataSource = dt
Me.DataGrid1.DataBind()