Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

Re: Connecting to a MS SQL 2k Server

by MrCromeDome (Deacon)
on Jul 24, 2003 at 21:36 UTC ( #277701=note: print w/replies, xml ) Need Help??

in reply to Connecting to a MS SQL 2k Server

What's wrong with DBD::ODBC? Not installed? Can't install? Want Win32::ODBC for some reason? What OS is your Perl script running on? Linux? Win32?

Throw me a bone here! ;) I can't help without more info.


Replies are listed 'Best First'.
Re: Re: Connecting to a MS SQL 2k Server
by Eagle_f90 (Acolyte) on Jul 24, 2003 at 21:44 UTC
    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.
      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.
      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
Node Status?
node history
Node Type: note [id://277701]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (3)
As of 2021-04-12 07:18 GMT
Find Nodes?
    Voting Booth?

    No recent polls found