Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

Re: Re: Connecting to a MS SQL 2k Server

by Eagle_f90 (Acolyte)
on Jul 24, 2003 at 21:44 UTC ( [id://277706]=note: print w/replies, xml ) Need Help??

in reply to Re: Connecting to a MS SQL 2k Server
in thread Connecting to a MS SQL 2k Server

Sorry, was not thinking before submitting that info.
There is nothing wrong with it. This is for a message board that connects to the database of a user's chocice for it's backend. So some people don't have ODBC installed, some can't get it installed, other just don't want to install it. The perl script will be runing on all differant OSes but mainly windows and *nix. I have already created a script to connect using ADO and ODBC, just don't know how to make one that just does not use either one of thouse.
  • Comment on Re: Re: Connecting to a MS SQL 2k Server

Replies are listed 'Best First'.
Re: Re: Re: Connecting to a MS SQL 2k Server
by dragonchild (Archbishop) on Jul 24, 2003 at 22:13 UTC
    To communicate with a database, you have to have a client that speaks that database's language. The various DBD:: modules communicate with those clients. The model looks something like:
    Perl code <-> DBI <-> DBD:: <-> Database client <-> Database
    In other words, if they want to connect to database XYZ, they have to have the client for XYZ installed and the appropriate DBD::. Then, you have to support XYZ's connection string.

    Those connection strings do differ between databases, as do the files necessary to support them. For example, DBD::Sybase (which is used to connect from Unix to SQL Server) can use freetds, which uses a file called freetds.conf. However, DBD::Oracle uses an oracle client which requires (usually) a file called tns.ora. It's not as simple as installing the right DBD:: module.

    In other words ... either you have to control the database choices on your server or you have to provide a mechanism for people who install your stuff to be able to connect to their DB of choice. Good luck! :-)

    We are the carpenters and bricklayers of the Information Age.

    Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.

    Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.

      We are controlling the choices, they will only be able to connect databases we allow them to, so far it is a flatfile and mySQl databes, I am working on the MS SQL 2k database. I have created scripts to connect though the ODBC and the ADO but want to creat a script that does not use thouse, I know in ASP you can do it (it's called a DNS-less connection). And was hoping that there is something like that in perl.
Re: Re: Re: Connecting to a MS SQL 2k Server
by MrCromeDome (Deacon) on Jul 24, 2003 at 22:06 UTC
    This sounds. . . interesting ;)

    Is this a CGI app or a client/server app? If CGI, I take it this app is installed multiple times in multiple places? I'm just wondering why you need to have the different code. By using DBI, you can make it easy to switch between various databases and not have to change any code. Behold my untested (simple) example:

    if($dbms eq "mysql") { $driver = "mysql"; $db = "test"; $user = "root"; $pw = ""; } elsif($dbms eq "mssql" { $driver = "ODBC"; $db = "test"; $user = "sa"; $pw = ""; } my $dbh = DBI->connect("DBI:$driver:$db", $user, $pw, { RaiseError => 1});
    If you don't want to use ODBC, you might consider using DBD::Sybase. Haven't tried it, but SQL Server is derived from Sybase, so you might have some luck there.

    Is this what you're looking for, or am I completely misunderstanding?


      It is a CGI script. Is a message board system for web masters. It is installed from a setup script and they choose what database to use, flatfile, mysql, mssql, ect. And depending on what database they use the program uses a differant .pm file. I am trying to avoid having the users install extra modules. It already is using the DBI module. I see in your above exampe that the $driver scaler is set to ODBC, is that also useing the DBD::ODBC module?

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://277706]
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (4)
As of 2024-04-20 16:48 GMT
Find Nodes?
    Voting Booth?

    No recent polls found