How to retrieve data from MSAccess database ?

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

Please do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.

This forum is for discussing mojoPortal development

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

You can monitor commits to the repository from this page. We also recommend developers to subscribe to email notifications in the developer forum as occasionally important things are announced.

Before posting questions here you might want to review the developer documentation.

Do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.
This thread is closed to new posts. You must sign in to post in the forums.
12/23/2010 11:49:14 PM
Gravatar
Total Posts 26

How to retrieve data from MSAccess database ?

Hai,

          I'm creating new Custom Feature which retrive data from MS access. The steps i have followed are:

1. User controls and the relavent classes are created.

2. I added the access database(mb.mdb) into solution(sample.web.ui).

3.In user control page_load() event i call the service class to retrieve the data from mb.mdb.

4. I specified the connection string as

" string source = AppDomain.CurrentDomain.BaseDirectory;

conString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + source + @"\database\db.mdb";"

5.Now i compiled my solution and there is no error and then i open my solution in explorer and copied dll(sample.web.ui.dll) from bin.

6. I pasted my dll into wwwroot\bin\ and added the database into wwwroot\bin\database\mb.mdb.

7. Finally when i added this feature manually to the mojoportal and add this feature to a page.there is no error is displayed in the systemlog,but

I am getting Design part only, mojoportal does not connect with the access database

  Any solution? How can i specify the connection string?

12/24/2010 8:43:53 AM
Gravatar
Total Posts 18439

Re: How to retrieve data from MSAccess database ?

Hi,

Sorry but I would not recommend using an Access database for any web application and cannot offer any support for it. MS Access is not designed for web apps and it would require MS Access runtime to be installed on the server to even try to use it.

It is incorrect to say "mojoportal does not connect with the access database". mojoPortal is not trying to connect to your custom access database, only your custom code is trying to do that and you must figure out what is wrong in your code. It is most likely the connection string and there are resources on the web where you can find out how to construct your connection string for Access. 

My recommendation is use a different db platform not MS Access. However if you do use MS Access I would advise you to put the .mdb file in the App_Data folder, if you put it anywhere else then someone can request the file with http://pathtoyour/db.mdb and steal your database.

I think in your connection string you are confusing virtual paths and file system paths. If you put the file in App_Data you could resolve the path like this:

string pathToDb = Server.MapPath("~/App_Data/db.mdb");

Hope it helps,

Joe

You must sign in to post in the forums. This thread is closed to new posts.