Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

database connection-urgent..

Status
Not open for further replies.

parames

MIS
Jun 26, 2000
71
MY
hi list , need help..

I'm using MS-SQL database and it is in different server. My perl pages (*.pl) resides in another server. How to connect to this database using IP address,database name, userid, password of the database server. Please help, i'm really going crazy with this..

Thanks a lot.
Parames.s
 
Try some form of this. It works for mysql.
Code:
use DBI;
my $host = "yourhost";
my $port = "yourport";
my $name = "yourdbname";
my $user = "youruserid";
my $pswd = "yourpassword";

# You may have to substitute something else for mysql
my $dsn = "DBI:mysql:database=$name;host=$host;port=$port";

$dbh = DBI->connect($dsn, $user, $pswd) || CgiError(DBI::errstr);
Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
hello tsdragon.. thanks for your reply

I still couldn't connect to the database. You wrote
my $dsn = "DBI:mysql:database=$name;host=$host;port=$port";

but, i'm not using mysql database i'm using Microsoft SQL database (MS-SQL). I've tried use
DBI:SQLOLEDB:database...

But, when i view the page online, nothing comes out.. the page is blank.. i don't know where is the problemm... please help.

rgds,
parames.s
 
Assuming your .pl script also resides on a Windows box on the same network, the easiest way would be to create a system dsn datasource in Control Panel/ODBC32 (or Control Panel/Admin Tools/Data Sources in Win2k) that points to the second server's SQL database. Then, in your .pl script simply use the name of the new datasource to access the database on the second computer. Let Windows do the work!

This is what I did and it works pretty well.

Tiz
 
...I also assume you're using DBI:ODBC...
 
Thanks for helping me try to help parames with this tiz. My programs are running on Unix boxes accessing mysql databases on other Unix boxes, so I didn't think my answer was exactly right, but I'd hoped I could at least point him in the right direction. Apparently it wasn't quite enough.
Can you suggest what changes he might need to make to the dsn string to make it work?
Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
Hi need some help

I am working on the MySQL database on the Unix Server.How to import the text file containing the data's from client pc to a particular table in the database.
I tried with following syntax via phpMyadmin Screen.

load data local infile "c:\\add.txt"
into table item;

Is the above syntax is correct.Please suggest.
 
I don't think you can load the data from your local PC to the remote host. You'll probably have to ftp the data file to the machine that the mysql database is on. Then this is the syntax I use:
Code:
load data local infile '/path/to/your/file/add.txt'
	into table item
	fields optionally enclosed by '"'
	(field,field,field);
Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard.
 
hey do u know the exact solution of hos to create a DSN for MS SQL server if so please let me know thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top