I am developing in ASP 3.0 and am facing a problem. I hope you will not mind helping me out.
I have two databases (both are Microsoft Access 2000). One is uploaded to a Web server, and one is located at my local computer. I want to update the online database from the local access database.
Once the first .mdb (Access database file) is uploaded to the Web server, it will be updated through an ASP page. The page is located on the Web server and will be visited from my own computer. This page will select (via a SQL query) all records from the locally saved .mdb file and then insert these records into the uploaded database file.
It is easy to insert selected records from the table from one .mdb file to another .mdb file if both .mdb files are on same server. In my case, one .mdb file is on the Web server and the second one is in my local computer. My problem is connecting them to the local database.
Any advice you can give me would be appreciated.
QUESTION POSED ON: 16 SEP 2005
QUESTION ANSWERED BY: Andrew Young
Thinking out loud…
Obviously the page performing the actions is on the Web server. So we must set up a share that the server can recognize on your local machine, which is where the database resides. For obvious reasons this application will only work from your machine. A physical location for the connection object should work as long as we have the security to access the database correctly configured. You can have concurrent connection objects open, but it might be cleaner and improve performance to store the data retrieved from the local database within corresponding application variables. Although if there are lots of records, that could become messy. Let's just transfer each record as we iterate through the recordset retrieved from the local database.
Let's begin with the share to the local database. Create the share and make sure to give permission to the "IUSR_<servername>", the default account for the Web server, not for the local machine. On the server, go to the users' accounts in the Control Panel and find the exact name of this user. It should be in the format above. As for the share, you will refer to it in the code by the UNC name, which is clearly defined here.
Create the connection to the local database:
Dim CS, DRV, DBQ, C1, RS1
DRV = "Driver={Microsoft Access Driver (*.mdb)}; "
DBQ = "DBQ= \\<computername>\<sharename><path>\<filename>;"
It sounds like you already have the connection objects, etc., for the database on the server resolved. At this point, you should be able to iterate through the records and write them to the server database. Use the EOF argument on your recordset and use the addNew method to write the local records to the recordset object that represents the server database. I have never tried a connection object using this approach, so let me know how it works out if you have a chance.
|