Home | Advertising Info80 USERS CURRENTLY ONLINE   
   Site Search Contact Us Wednesday, July 30, 2014  
 
 







DISCUSSION ARCHIVES
DISCUSSION ARCHIVES 2
DISCUSSION ARCHIVES 3
BLOG

 
Try a free httpZip trial now and compress for less!


We didn't realize
the site was so popular.

Other Stuff
 
 


Using FrontPage To Set Up a Database Connection





Many people use FrontPage to manage their hosted websites running on Microsoft IIS servers. Often times ASP applications such as the ones I sell at CJWSoft need a properly set up data connection in order to run. This means a System or DSN-Less connection must be set up and that information must be entered into a connection string that the application will use to communicate with the database. Often times this also means that proper permissions must be set on the directory the database will be in. This is sometimes easier said than done because some web hosting companies can be a real "Pain in the Ass !".

Luckily there is a trick you can do using FrontPage to set up your database connection. Now, this trick does not always work as some hosts have altered permissions and what not too much which can mess up the process, but a lot of times this will work and its really a pretty easy thing to do.

Basically, your going to want to connect your site live with FrontPage. To do this open FrontPage explorer and choose "file/open site". Now, for the site name enter the whole url to your site including the "http://" info. Like so: http://www.mysite.com. If FrontPage extensions are installed in your site it will prompt you for credentials to log in to your site so log in to your site.

Once your in you should see something similar to this.

Now, in folder view drag an MSAccess database file from your system into a folder in your site. It really doe not matter where because we will get the option to put it where we want it when FrontPage processes it. So, for now just drag it into the root of your web site. I am going to use a file called "aspprotect.mdb" which is used in the ASPProtect application that I sell.

As it imports the file into the web you should get this prompt.



Give the connection a name. Don't use spaces and keep it simple.
I called mine "aspprotect"



I recommended saying yes to this prompt and storing any databases you set up in the same folder.



Now, when you do this FrontPage will edit your existing "global.asa" file or create a new one in your web site. The "global.asa" file is a file that runs when certain events happen. More info on that is available here.

In your "global.asa" it will add a bunch of crazy looking functions that it uses to set up the database connection. That information needs to be there so do not delete it. The part you are concerned with will look like this.

'==FrontPage Generated - startspan==
Dim FrontPage_UrlVars(1)
'--Project Data Connection
Application("aspprotect_ConnectionString") = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=URL=fpdb/aspprotect.mdb"
FrontPage_UrlVars(0) = "aspprotect_ConnectionString"
Application("aspprotect_ConnectionTimeout") = 15
Application("aspprotect_CommandTimeout") = 30
Application("aspprotect_CursorLocation") = 3
Application("aspprotect_RuntimeUserName") = ""
Application("aspprotect_RuntimePassword") = ""
'--
Application("FrontPage_UrlVars") = FrontPage_UrlVars
'==FrontPage Generated - endspan==

Your going to use the part in blue as your connection string in your ASP application.

So, in the case of ASPProtect the connecting string would usually look like this.

ConnectionString = "DBQ=C:\Inetpub\wwwroot\aspprotect\data\database\ASPProtect_access2002.mdb;Driver={Microsoft Access Driver (*.mdb)};UID=Admin;Password=temp"

instead of that you would use this

ConnectionString = Application("aspprotect_ConnectionString")

Bacially Frontpage did all the work for us. It figured out the physical path to the database and set permissions for us.

Now, there is one problem with what we just did. The MSACCESS database used for ASPProtect is password protected with a default password. (You can change it using MSACCESS but that is not the focus of this article)

In order for our Frontpage connection string to work we need to edit the "global.asa" file and add the Username and Password.

'==FrontPage Generated - startspan==
Dim FrontPage_UrlVars(1)
'--Project Data Connection
Application("aspprotect_ConnectionString") = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=URL=fpdb/aspprotect.mdb
;UID=Admin;Password=temp"
FrontPage_UrlVars(0) = "aspprotect_ConnectionString"
Application("aspprotect_ConnectionTimeout") = 15
Application("aspprotect_CommandTimeout") = 30
Application("aspprotect_CursorLocation") = 3
Application("aspprotect_RuntimeUserName") = "
Admin"
Application("aspprotect_RuntimePassword") = "
temp"
'--
Application("FrontPage_UrlVars") = FrontPage_UrlVars
'==FrontPage Generated - endspan==

Notice the parts highlighted in red with white text that we added.
"Admin" is the default username when working with MSAccess and you do not change that.

That is all there is to it. If your database does not use a password you do not have to worry about that part. If your FrontPage connection string does not work then you are one of the lucky few that has a hosting company that messed up this default behavior.

The other nice thing about this is that FrontPage will give only the permissions needed to the "FPDB" folder and it will also set the folder to not allow files to be browsed. This is nice because even if someone knows the URL location of your database they will not be able to download it by typing it in via the web browser.

I learned this little trick because I do a lot of installation for my CJWSoft customers and there were times when I had to do this in order to set up a working data connection because the hosting company was not helpful in setting permissions anywhere in the web.

On a side note: I know a lot of people rag on FrontPage mostly because it creates a lot of bloated html, but it really can be a nice tool when working with IIS hosted websites that have the FrontPage extensions installed. I do most of coding by hand or using other editors, but FrontPage is my tool of choice when it comes to managing and connecting to my websites. There is hands down no faster way to connect to and edit a page in your site especially since most of the time you can just click on the "EDIT" icon in internet explorer and be editing a page in your site live in a matter of seconds. I seldom use FTP unless I am transferring a lot of file or large files to and from my sites. FrontPage has really come a long way over the years and connecting to a site using it is now a very rock solid operation unlike in the past.

 

   Active Server Pages Rule The World
Contact Us  
All artwork, design & content contained in this site are Copyright 1998 - 2014 PowerASP.com and Christopher J. Williams
Banner ads ,other site logos, etc are copyright of their respective companies.
STATS Unless otherwise noted - All Rights Reserved.

Active Server Pages ASP ASP.NET .aspx .ascx Web HTML Developer Internet Microsoft Web Services Visual Studio .NET CJWSoft ASPProtect ASPBanner ASPClassifieds www.aspclassifieds.com, www.powerasp.com,www.cjwsoft.com,www.aspphotogallery.com,www.codewanker.com,www.aspprotect.com,www.aspbanner.com