Web Site Creator Web Hosting Help
   Accessing Databases


Here are two sample ways to connect to a database.  We recommend placing one of the below methods into an include file. The include file should only contain the information below and any other database access information so you only have to configure it once, regardless of how many times you use it, or how many pages use it. If the information ever needs to be changed, you will only need to update it once in one place.

Replace the username, password, and database with the information that relates to your specific database before using.  We have capitalized and bolded the sections that you will need to modify before use.

How to access SQL Server using ODBC

Every user that has a SQL Server database also has a built in DSN called "UserDBConn".  This name will not change.  Here is how to access your SQL Server in PERL using your assigned DSN. 

#!c:\perl\bin\perl.exe

use CGI;
use DBI;
my $db = 'DBI:ODBC:UserDBConn';
my $username = 'UserName';
my $pass = 'Password';
my $db_object = DBI->connect($db, $username, $pass);

How to access MySQL Server
Every one of our web sites can utilize the MySQL databases as they come free. You must ensure that you create the database from inside the Web Hosting control panel before you attempt to use it. Here is sample code for establishing a connection to the database:

#!c:\perl\bin\perl.exe
 
 use CGI;
 use DBI;
 
 my $db = 'DBI:mysql:DATABASE:mysqldb1.ehost-services.com';
 my $username = 'Username';
 my $pass = 'Password';
 
 my $db_object = DBI->connect($db, $username, $pass);

Sign Up Now! Overview

Questions? Call sales at
1 (425) 274-4500
Or try our
Visit our Help Center where you can get simple and quick product support.
   is an affiliate of   , a leading domain name services company.
Copyright © 1998-2018 Enom LLC. All rights reserved. Terms & Conditions | Privacy Policy | Abuse Policy