I use the following in my Perl CGI:

#
# Database Settings
#

$db_user     = "iusr_xxx";
$db_pass     = "password";
$dsn_name    = 'dbi:ODBC:MyDB';

sub dbh_connect
{
        my ($q);

        $q = new CGI;  
        
        $dbh = DBI->connect($dsn_name, $db_user, $db_pass, {
                PrintError => 1,
                AutoCommit => 1
                });

      if(!defined($dbh))
      {
        print $q->header,
                  $q->start_html(   -title      => "Database Error",
                            -background => $BACKGROUND),
              $q->p("Error connecting to DSN '$dsn_name'"),
                  $q->p("Error was:"),
                  $q->br,
                  $q->p("$DBI::errstr:$DBI::err"),
                  $q->end_html;

        return 0;
        }

      return 1;
}

I also use the following steps to set up the DSN:

•     Go to Start -> Settings -> Control Panel -> Administrative Tools ->
Data Sources
•     Click on the System DSN tab
•     Click on the Add... button
•     Select SQL Server from the list, and click Finish
•     Enter the name for the DSN
•     For Description, enter something descriptive
•     For Server, enter the server name
•     Click on the Next button
•     Verify that "With SQL Server authentication using a logon ID and
password entered by the user" is selected
•     Put a check in "Connect to SQL Server to obtain default settings..."
•     Enter the user ID to connect with
•     Enter the password to connect with
•     Click on the Next button
•     Place a check mark in Change the default database to, and select the
correct Database
•     Click on the Next button
•     Click on the Finish button
•     Click on the Test Data Source... button
•     If an error occurs, contact the database owner, otherwise, click OK

--
Benjamin D. Wiechel
Xerox Connect
[EMAIL PROTECTED]
http://members.toast.net/strycher/

 

-----Original Message-----
From: harsha reddy [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, March 26, 2003 3:38 PM
To: Zoltan Ness; [EMAIL PROTECTED]
Subject: RE: Perl Database Problem


Dear All,
          I have tried all the things that you have
mentioned but the problem hasnt gone,there are some
particular files that i need to access in order to
setup a connection with the database, the first one is
a perl module called sys_init.pm where the initial
values are given and a module called dbase.pm where
the connection string is described , they are as
follows.
sys_init.pm:

sub system_init {

# The following variable determines the display of the
client's name in
# HTML titles and page-level titles.
#
---------------------------------------------------------------------
        $client_name = "RUCDRTest";

# The following variables tell the system what
external URL the system
# can be found at in order to correctly execute
redirects.
#
---------------------------------------------------------------------

# foo_url should end with a slash.
#
---------------------------------------------------------------------
        $client_url = "http://xxxxxxx/RUCDRTest/";;
        $redir_url = "http://xxxxxxx/RUCDRTest/";;


# The following variables tell the system what it
needs to know about
# the server it's using to store workflow information
on.  sql_server
# and sql_port can be left blank for default values;
the rest need to
# be filled in completely.
#
---------------------------------------------------------------------
        $sql_server = "";
        $sql_port = "RUCDRTest";
        $sql_driver = "ODBC";
        $sql_dbase = "RUCDRTest";
        $sql_uid = "";
        $sql_pwd = "";



dbase.pm:

 ---> CONNECT DB: Connect to the database.
### ### ### ### ### ### ### ### ### ### ### ### ###
### ### ### ### ### ###
sub connect_db() {

        $dsn = "DBI:$sql_driver:$sql_dbase";
        $dbh = DBI->connect($dsn, $sql_uid, $sql_pwd);
}
### ### ### ### ### ### ### ### ### ### ### ### ###
### ### ### ### ### ###


# ---> DISCONNECT DB: Disconnect from the database.
### ### ### ### ### ### ### ### ### ### ### ### ###
### ### ### ### ### ###
sub disconnect_db() {

        $dbh->disconnect();
}


and here is  part of the code for the asp access in
the global.asa file

Application("DSN")                      =
"DSN=RUCDRTest;UID=sa;PWD=sqladmin"   ' Our dsn for
the application
    Application("SessionTimeOut") = 120     ' User
timeout in minutes
    Application("HTTP")  = "http://xxxxxx/RUCDRTest/";
    Application("HTTPS") = "http://xxxxxx/RUCDRTest/";

in the original file only the RUCDRTest is changed to
RUCDR, the asp updates work perfect in the new one.

i would really appreciate your help in this matter.

thank you
harsha


--- Zoltan Ness <[EMAIL PROTECTED]> wrote:
> While you did mention that you adjusted the DSN,
> that is the most likely location of the problem. 
> The DSN should be pointed to the backup database
> instance.  The name of the DSN does not matter, as
> long as it is unique and the perl script is pointing
> to it.  Here are a few steps:
> 
> 1.    Check on SQL Server what the backup db name is
> (and that it is started).
> 2.    Configure the DSN with that server and dbname.  
> 3.    Test the data source connection.
> 
>  
> 
>       -----Original Message----- 
>       From: harsha reddy [mailto:[EMAIL PROTECTED] 
>       Sent: Tue 3/25/2003 13:18 
>       To: [EMAIL PROTECTED] 
>       Cc: 
>       Subject: Perl Database Problem
>       
>       Dear All,
>                 I am working on a SQL server database
> that
>       uses ASP and PERL to fetch and update data, I have
>       made a copy of the Original database and am making
>       changes to it, the original database's name is
> RUCDR
>       and the new one is RUCDRTest.
>       
>       Everything seemed to be working fine until i
>       discovered that the perl files that access and
> update
>       the data are actually fetching and storing the data
>       from the main database instead of the copy i
> created,
>       whereas the ASP files access data from the new
>       database, I have made sure that all the paths that
>       earlier pointed to the main database have been
> changed
>       to point to the new one, even the DSN name is
>       different.
>       
>       I would really appreciate it if someone could help
> me
>       out in this matter.
>       
>       regards
>       harsha
>       
>       
> 
>
=êåZ)÷Ø
fŠyšŠX§‚X¬´÷«•h§ß`š)åŠËlz»Àrدy+Zµç(™:.žË›±Êâmèm¶Ÿÿ–+-±êïËb½ä­jל¢oæj)fjæ
ÊË›


__________________________________________________
Do you Yahoo!?
Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop!
http://platinum.yahoo.com
_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to