I have a website built that uses MySql for data management. Everything works great there, however, I am now trying to add our web statistics to it - we have a generic standard that we use. This requires a connection to an MS Access database for login - user name and password, checks acess to that specific site.
The stats work fine on any site that uses MS Access for it data, but I'm having trouble getting the MS Access connection to work with the site that uses MySql.
Here is our basic setup:
folders:
main=site/2009 stats=site/webstatsMain site - MySql - web.c开发者_如何学运维onfig has connection setup for MySql
webstats is setup as a virtual directory in iis under the site and has its own web.config file. The connection here is defined as MS Access, but the default.aspx fails when the user tries to log in (connect to the db and check password)
Does anyone know what I can do to make the system use the connection from the child?
Thank you,
Christy
Resurrecting a thread, but here goes.
EntitySpaces 2010 has a fancy feature called MultiProvider mode, however this requires both databases to have the same schema. I'm going to include a link to it for reference multi-provider-mode
Now, to gain a connection to two separate databases with different structures, you should generate your primary database connection first. Either through the VisualStudio addin, or via the standalone. Add your connection string to your web.config, and register the loader.
Add the required references:
- EntitySpaces.core.dll
- EntitySpaces.DebuggerVisualizer.dll
- EntitySPaces.DynamicQuery.dll
- EntitySpaces.Interfaces.dll
- EntitySpaces.Loader.dll
- EntitySpaces.MSAccessProvider.dll
- EntitySpaces.MySQLProvider.dll
- EntitySpaces.Web.dll
Once you have those loaded and registered, test your connection to MySQL. If it returns successful, and you're able to run your CRUD on MySQL, you're ready to move on to phase 2, connecting to Access
Load up the StandAlone version of EntitySpaces, and select Access as the database type from the setup dropdown. Click on configure connection.
- If you're using Access .mdb files, you can just enter your username/password for the DB here.
- If you have an Access2007 .accdb file, you need to click on the advanced tab and change the provider to Microsoft.ACE.OLEDB.12.0
From there, close the database configuration dialogue and open the Naming Conventions tab. Change the Abstract Prefix from "es" to "ac"
now you're ready to generate your templates. I chose to generate my Generated and Custom templates for Access in a different namespace so it was easy for me to distinguish what area I was programming in, also it wont include the generated Access files on my pages that only need access to my SQL database. Take special note to the Connection Name field here, set it to something memorable such as AccessConnection
Once they are generated (its ok to place them in the same directory, assuming the filenames dont overlap), you need to add the Access Connection string to your web.config, it will look similar to your SQL connection string.
<add name="AccessConnection" providermetadatakey="esDefault" sqlaccesstype="DynamicSQL" provider="EntitySpaces.MSAccessProvider" providerclass="DataProvider" connectionstring="User ID=Admin;Data Source=|DataDirectory|SchoolData.mdb;Persist Security Info=True"></add>
From here, simply include your Access namespace in your asp page and start using the EntitySpaces dynamic query language.
精彩评论