Developer forum

Forum » Development » Database access from UserControl

Database access from UserControl


Reply

Hi

 

I have created a UserControl, which reads and writes to a Access database located in the File structure. Is that posible using the standard Dynamicweb Database class ?

 

/Anders


Replies

 
Reply

If you dump it in the Database folder, there shouldn't be a problem. If it's in Files or one of it's subfolders, I'm not sure. Try with "../Files/Filer/MyDB.mdb" as the database parameter.
 

 
Nicolai Høeg Pedersen
Reply
Sorensen wrote:

If you dump it in the Database folder, there shouldn't be a problem. If it's in Files or one of it's subfolders, I'm not sure. Try with "../Files/Filer/MyDB.mdb" as the database parameter.
 


 

It will work...

 
Reply

HI

 

The full path seems not to work. The UserControl is located in "/Files/Filer/System/UserControl/SubscribeCampaign.ascx" and our database is located in "Files/Filer/Database/DBStudyAbroad.mdb". However using the database path as "../Files/Filer/database/DBStudyAbroad.mdb" in the UserControl code doesn't work.

 

As a test we have succeeded in reading all users from the AccessUser table in the Access.mdb database using the code in the UserControl and the relative database path "Access.mdb".

 

Please help us with the right database path

 

CU

Kim & Anders

 
Nicolai Høeg Pedersen
Reply
kim@occinnovation.dk wrote:

HI

 

The full path seems not to work. The UserControl is located in "/Files/Filer/System/UserControl/SubscribeCampaign.ascx" and our database is located in "Files/Filer/Database/DBStudyAbroad.mdb". However using the database path as "../Files/Filer/database/DBStudyAbroad.mdb" in the UserControl code doesn't work.

 

As a test we have succeeded in reading all users from the AccessUser table in the Access.mdb database using the code in the UserControl and the relative database path "Access.mdb".

 

Please help us with the right database path

 

CU

Kim & Anders


 

Hi Kim

 

If the website is running on SQL-Server, the access database cannot be reached through Database class because it will redirect all calls to the SQL-server and ignore the second parameter, database.

 

If running on Access try like this instead: Database.getconn("..\Files\Filer\database\DBStudyAbroad.mdb")

 
Reply

If you just need to upload the database once, you could also upsize it to the SQL server.

 
Reply

You could also access the database using your own connection:

 

Dim Con As IDbConnection
Con = New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=PathToDatabase")

 

 
Reply
Sorensen wrote:

You could also access the database using your own connection:

 

Dim Con As IDbConnection
Con = New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=PathToDatabase")

 

Hi Lars
 

 

Well, that's another approach to access the the database.

 

Before changing the entire database access code in my UserControl, I would like you to verify that (or not) the Dynamicweb.Database class is able to use *.mdb access-database files outside the standard Database folder in the Dynamicweb CMS folder structure ?

 

/Anders 

 
Reply

Well, not when running SQL server.

 

Would the Database Publishing modul be able to serve the same purpose as your control? That way you could use built-in functionality rather that custom code.

 

You must be logged in to post in the forum