can"t execute "use $database"

can"t execute "use $database"

am 07.02.2007 05:48:47 von patrixdiradja

--0-1163720369-1170823727=:3832
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit

Dear my friends,

I wonder why my perl can not execute query "use $database".

Please tell me where is my fault.

Here is the error message and my code:
===
#error message
DBD::ADO::db do warning: Can't Execute 'use gua'
===
#my code:
#!/usr/bin/perl
use strict;
use DBD::ADO;
use DBI;
my $dsn="sigma";
my $uname="sa";
my $pword="penguin";
my $host="127.0.0.1";
my @bd4l=("gua");

print "I am dumping... @bd4l\n";
my $elemenbd4l;
foreach $elemenbd4l(@bd4l){
my $strbd4l="use $elemenbd4l";
print "$strbd4l\n";
my $dbh1 = DBI->connect("dbi:ADO:$dsn", $uname, $pword)
|| die "Could not open SQL connection.";
my $rsnya = $dbh1->do($strbd4l);


---------------------------------
Kunjungi halaman depan Yahoo! Indonesia yang baru!
--0-1163720369-1170823727=:3832--

RE: can"t execute "use $database"

am 07.02.2007 15:33:54 von Philip.Garrett

Patrix Diradja wrote:
> Dear my friends,
>=20
> I wonder why my perl can not execute query "use $database".

Sorry, I don't know for sure, but my guess is that the "use "
command is a *client* command, and not valid SQL.

Generally speaking, when you want to connect to a specific database, it
should be part of your DSN. You would specify the database name in the
Windows ODBC manager. Or, if you're using connect strings, you'd
specify it there.

Your code indicates that, at some point, you will want to connect to
several different databases using the same DSN. Rather than trying to
force the same $dbh to connect to a different database, why not
disconnect and then reconnect to the new database?

Regards,
Philip

Balasan: RE: can"t execute "use $database"

am 07.02.2007 19:10:24 von patrixdiradja

--0-617799961-1170871824=:17102
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit

Dear my friend, Charles.

I Use Perl on Windows Vista, MS SQL Server 2005, DBI, ADO.

I create 'myperl' as DSN from ODBC Administration Tools.

Here is my connection string:
my $dbh1 = DBI->connect("dbi:ADO:database=gua;host=127.0.0.1;port=1433" , $uname, $pword)
|| die "Could not open SQL connection."


But why the connection is failed?

Here is the error message:
DBI connect('database=gua;host=127.0.0.1;port=1433','sa',...) failed: Can't Open Connection 'database=gua;host=127.0.0.1;port=1433'

Please tell me why.

"Garrett, Philip (MAN-Corporate)" wrote:
Patrix Diradja wrote:
> Dear my friends,
>
> I wonder why my perl can not execute query "use $database".

Sorry, I don't know for sure, but my guess is that the "use "
command is a *client* command, and not valid SQL.

Generally speaking, when you want to connect to a specific database, it
should be part of your DSN. You would specify the database name in the
Windows ODBC manager. Or, if you're using connect strings, you'd
specify it there.

Your code indicates that, at some point, you will want to connect to
several different databases using the same DSN. Rather than trying to
force the same $dbh to connect to a different database, why not
disconnect and then reconnect to the new database?

Regards,
Philip



---------------------------------
Kunjungi halaman depan Yahoo! Indonesia yang baru!
--0-617799961-1170871824=:17102--

Balasan: RE: can"t execute "use $database"

am 07.02.2007 19:11:10 von patrixdiradja

--0-2029389419-1170871870=:1257
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit

Dear my friend, Garret.

I Use Perl on Windows Vista, MS SQL Server 2005, DBI, ADO.

I create 'myperl' as DSN from ODBC Administration Tools.

Here is my connection string:
my $dbh1 = DBI->connect("dbi:ADO:database=gua;host=127.0.0.1;port=1433" , $uname, $pword)
|| die "Could not open SQL connection."


But why the connection is failed?

Here is the error message:
DBI connect('database=gua;host=127.0.0.1;port=1433','sa',...) failed: Can't Open Connection 'database=gua;host=127.0.0.1;port=1433'

Please tell me why.

"Garrett, Philip (MAN-Corporate)" wrote:
Patrix Diradja wrote:
> Dear my friends,
>
> I wonder why my perl can not execute query "use $database".

Sorry, I don't know for sure, but my guess is that the "use "
command is a *client* command, and not valid SQL.

Generally speaking, when you want to connect to a specific database, it
should be part of your DSN. You would specify the database name in the
Windows ODBC manager. Or, if you're using connect strings, you'd
specify it there.

Your code indicates that, at some point, you will want to connect to
several different databases using the same DSN. Rather than trying to
force the same $dbh to connect to a different database, why not
disconnect and then reconnect to the new database?

Regards,
Philip



---------------------------------
Sekarang dengan penyimpanan 1GB
http://id.mail.yahoo.com/
--0-2029389419-1170871870=:1257--

RE: Balasan: RE: can"t execute "use $database"

am 07.02.2007 19:36:49 von Philip.Garrett

Patrix Diradja wrote:
> Dear my friend, Garret.
>=20
> I Use Perl on Windows Vista, MS SQL Server 2005, DBI, ADO.
>=20
> I create 'myperl' as DSN from ODBC Administration Tools.
>=20
> Here is my connection string:
> my $dbh1 =3D
> DBI->connect("dbi:ADO:database=3Dgua;host=3D127.0.0.1;port=3 D1433",
> $uname, $pword) || die "Could not open SQL connection."=20

Your 'myperl' DSN should already know the database, host and port names.
Once you have configured that DSN, you just reference it by name:

my $dbh =3D DBI->connect('dbi:ADO:myperl', $uname, $pword)
|| die $DBI::errstr;

Regards,
Philip

Balasan: RE: Balasan: RE: can"t execute "use $database"

am 07.02.2007 19:56:51 von patrixdiradja

--0-1286763833-1170874611=:13502
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit

Yeah, that's the problem Garrett.

I usually use that way to connect to ms msql.

But now, I want that my perl code can work with several databases. So I need somewhat like the Connection String which I can modify (forming string) and than just does "$dbh->connect(<>)". and does "$dbh->close" before doing again connect to another database ($dbh->connect).

Imagine if my perl code work with 50 databases than it means I have to create 50 DSN such the 'myperl'. It's not automatically enough and make my life so difficult.

Please tell me furthermore.

"Garrett, Philip (MAN-Corporate)" wrote:
Patrix Diradja wrote:
> Dear my friend, Garret.
>
> I Use Perl on Windows Vista, MS SQL Server 2005, DBI, ADO.
>
> I create 'myperl' as DSN from ODBC Administration Tools.
>
> Here is my connection string:
> my $dbh1 =
> DBI->connect("dbi:ADO:database=gua;host=127.0.0.1;port=1433" ,
> $uname, $pword) || die "Could not open SQL connection."

Your 'myperl' DSN should already know the database, host and port names.
Once you have configured that DSN, you just reference it by name:

my $dbh = DBI->connect('dbi:ADO:myperl', $uname, $pword)
|| die $DBI::errstr;

Regards,
Philip



---------------------------------
Kunjungi halaman depan Yahoo! Indonesia yang baru!
--0-1286763833-1170874611=:13502--

RE: Balasan: RE: Balasan: RE: can"t execute "use $database"

am 07.02.2007 20:10:23 von Philip.Garrett

Patrix Diradja wrote:
> Yeah, that's the problem Garrett.
>=20
> I usually use that way to connect to ms msql.
>=20
> But now, I want that my perl code can work with several databases.
> So I need somewhat like the Connection String which I can modify
> (forming string) and than just does "$dbh->connect(< > for me>>)". and does "$dbh->close" before doing again connect to
> another database ($dbh->connect).

Ok, try this: (found on www.connectionstrings.com)

my $connstr =3D "Provider=3DSQLNCLI;"
. "Server=3D$server;"
. "Database=3D$database;";

my $dbh =3D DBI->connect("dbi:ADO:$connstr",$user,$pass)
|| die $DBI::errstr;

If you are using SQL Server 2005 Express, you'll need to add \EXPRESS
after the server name like this:
"Server=3D$server\\EXPRESS;"

Philip

Balasan: RE: Balasan: RE: Balasan: RE: can"t execute "use $database"

am 08.02.2007 16:53:57 von patrixdiradja

--0-156910032-1170950037=:76667
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit

Dear Garrett.... it still doesn't work.

Here is the error message:
Can't locate DBI/ADO.pm in @INC (@INC contains: C:\Program Files\ActiveState Perl Dev Kit 6.0\lib\ C:/Perl/site/lib C:/Perl/lib .) at cldump.pl line 8.
BEGIN failed--compilation aborted at cldump.pl line 8.

Please tell me furthermore.

here is my code:
#####
use strict;
use DBI::ADO;
use Win32::OLE;
use Win32::OLE::Const 'Microsoft ActiveX Data Objects';
use warnings;
my $uname="sa";
my $pword="penguin";
my $host="127.0.0.1";
my @bd4l=("FinanCore");
#if (@ARGV){
#my @bd4l=@ARGV;
#}else{
#my @bd4l=("AprovaApp1");
#}
print "I am dumping... @bd4l\n";
foreach my $elemenbd4l(@bd4l){
my $dsn = "Provider=SQLNCLI;"
. "Server=$host;"
. "Database=$elemenbd4l;";
my $dbh1 = DBI->connect("dbi:ADO:$dsn", $uname, $pword) or die $DBI::errstr;

####

"Garrett, Philip (MAN-Corporate)" wrote:
Patrix Diradja wrote:
> Yeah, that's the problem Garrett.
>
> I usually use that way to connect to ms msql.
>
> But now, I want that my perl code can work with several databases.
> So I need somewhat like the Connection String which I can modify
> (forming string) and than just does "$dbh->connect(<> for me>>)". and does "$dbh->close" before doing again connect to
> another database ($dbh->connect).

Ok, try this: (found on www.connectionstrings.com)

my $connstr = "Provider=SQLNCLI;"
.. "Server=$server;"
.. "Database=$database;";

my $dbh = DBI->connect("dbi:ADO:$connstr",$user,$pass)
|| die $DBI::errstr;

If you are using SQL Server 2005 Express, you'll need to add \EXPRESS
after the server name like this:
"Server=$server\\EXPRESS;"

Philip





---------------------------------
Kunjungi halaman depan Yahoo! Indonesia yang baru!
--0-156910032-1170950037=:76667--

RE: Balasan: RE: Balasan: RE: Balasan: RE: can"t execute "use $database"

am 08.02.2007 16:55:49 von Philip.Garrett

DBI::ADO is not a module. The module is DBD::ADO. But you don't need
to load it -- DBI will load it for you.

use DBI;
# DBI automatically loads ADO
my $dbh =3D DBI->connect('dbi:ADO:...',...);

-----Original Message-----
From: Patrix Diradja [mailto:patrixdiradja@yahoo.co.id]=20
Sent: Thursday, February 08, 2007 10:54 AM
To: dbi-users@perl.org
Subject: Balasan: RE: Balasan: RE: Balasan: RE: can't execute "use
$database"

Dear Garrett.... it still doesn't work.
=20
Here is the error message:
Can't locate DBI/ADO.pm in @INC (@INC contains: C:\Program
Files\ActiveState Perl Dev Kit 6.0\lib\ C:/Perl/site/lib C:/Perl/lib .)
at cldump.pl line 8.
BEGIN failed--compilation aborted at cldump.pl line 8.
=20
Please tell me furthermore.
=20
here is my code:
#####
use strict;
use DBI::ADO;
use Win32::OLE;
use Win32::OLE::Const 'Microsoft ActiveX Data Objects';
use warnings;
my $uname=3D"sa";
my $pword=3D"penguin";
my $host=3D"127.0.0.1";
my @bd4l=3D("FinanCore");
#if (@ARGV){
#my @bd4l=3D@ARGV;
#}else{
#my @bd4l=3D("AprovaApp1");
#}
print "I am dumping... @bd4l\n";
foreach my $elemenbd4l(@bd4l){
my $dsn =3D "Provider=3DSQLNCLI;"
. "Server=3D$host;"
. "Database=3D$elemenbd4l;";
my $dbh1 =3D DBI->connect("dbi:ADO:$dsn", $uname, $pword) or die
$DBI::errstr;

####

"Garrett, Philip (MAN-Corporate)" wrote:
Patrix Diradja wrote:
> Yeah, that's the problem Garrett.
>=20
> I usually use that way to connect to ms msql.
>=20
> But now, I want that my perl code can work with several databases.
> So I need somewhat like the Connection String which I can modify
> (forming string) and than just does "$dbh->connect(<> for me>>)". and
does "$dbh->close" before doing again connect to
> another database ($dbh->connect).

Ok, try this: (found on www.connectionstrings.com)

my $connstr =3D "Provider=3DSQLNCLI;"
.. "Server=3D$server;"
.. "Database=3D$database;";

my $dbh =3D DBI->connect("dbi:ADO:$connstr",$user,$pass)
|| die $DBI::errstr;

If you are using SQL Server 2005 Express, you'll need to add \EXPRESS
after the server name like this:
"Server=3D$server\\EXPRESS;"

Philip




=09
---------------------------------
Kunjungi halaman depan Yahoo! Indonesia yang baru!

Balasan: RE: Balasan: RE: Balasan: RE: Balasan: RE: can"t execute "use $database"

am 08.02.2007 17:24:27 von patrixdiradja

--0-1680428699-1170951867=:51126
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit

Garrett, you've saved me. Thank you....thank...you.....thanks..... thousands times.........

I really appreciate your help, Garrett.......

"Garrett, Philip (MAN-Corporate)" wrote:
DBI::ADO is not a module. The module is DBD::ADO. But you don't need
to load it -- DBI will load it for you.

use DBI;
# DBI automatically loads ADO
my $dbh = DBI->connect('dbi:ADO:...',...);

-----Original Message-----
From: Patrix Diradja [mailto:patrixdiradja@yahoo.co.id]
Sent: Thursday, February 08, 2007 10:54 AM
To: dbi-users@perl.org
Subject: Balasan: RE: Balasan: RE: Balasan: RE: can't execute "use
$database"

Dear Garrett.... it still doesn't work.

Here is the error message:
Can't locate DBI/ADO.pm in @INC (@INC contains: C:\Program
Files\ActiveState Perl Dev Kit 6.0\lib\ C:/Perl/site/lib C:/Perl/lib .)
at cldump.pl line 8.
BEGIN failed--compilation aborted at cldump.pl line 8.

Please tell me furthermore.

here is my code:
#####
use strict;
use DBI::ADO;
use Win32::OLE;
use Win32::OLE::Const 'Microsoft ActiveX Data Objects';
use warnings;
my $uname="sa";
my $pword="penguin";
my $host="127.0.0.1";
my @bd4l=("FinanCore");
#if (@ARGV){
#my @bd4l=@ARGV;
#}else{
#my @bd4l=("AprovaApp1");
#}
print "I am dumping... @bd4l\n";
foreach my $elemenbd4l(@bd4l){
my $dsn = "Provider=SQLNCLI;"
.. "Server=$host;"
.. "Database=$elemenbd4l;";
my $dbh1 = DBI->connect("dbi:ADO:$dsn", $uname, $pword) or die
$DBI::errstr;

####

"Garrett, Philip (MAN-Corporate)"
wrote:
Patrix Diradja wrote:
> Yeah, that's the problem Garrett.
>
> I usually use that way to connect to ms msql.
>
> But now, I want that my perl code can work with several databases.
> So I need somewhat like the Connection String which I can modify
> (forming string) and than just does "$dbh->connect(<> for me>>)". and
does "$dbh->close" before doing again connect to
> another database ($dbh->connect).

Ok, try this: (found on www.connectionstrings.com)

my $connstr = "Provider=SQLNCLI;"
.. "Server=$server;"
.. "Database=$database;";

my $dbh = DBI->connect("dbi:ADO:$connstr",$user,$pass)
|| die $DBI::errstr;

If you are using SQL Server 2005 Express, you'll need to add \EXPRESS
after the server name like this:
"Server=$server\\EXPRESS;"

Philip





---------------------------------
Kunjungi halaman depan Yahoo! Indonesia yang baru!



---------------------------------
Lelah menerima spam? Surat Yahoo! mempunyai perlindungan terbaik terhadap spam.
http://id.mail.yahoo.com/
--0-1680428699-1170951867=:51126--

Balasan: RE: Balasan: RE: Balasan: RE: Balasan: RE: can"t execute "use $database"

am 01.03.2007 23:26:17 von patrixdiradja

Hi, Garrett.

I am sorry because I reply this respond late. I am
just recovered from long sick. I had to take bed rest.

Well, I thank you so much for your help. Your thread
solved my problem.

Now, my code run as expected. It dumps the data
dictionary of the each database of my MSSQL.

Now I am doing the GUI with Perl/Tk before to the
further steps (user friendly installer, MS Office and
OpenOffice Macro Integration etc).

Could you tell me which mailing-list for Perl/Tk what
still active? I found a Perl/Tk mailing-list in
yahoogroups and joined it. But the mail-list only
content dirty disgusting porno everyday. Meine
Guete....

Please refer me to a good Perl/Tk mailing-list. I
wanna be a perlmonk.
--- "Garrett, Philip (MAN-Corporate)"
wrote:

> DBI::ADO is not a module. The module is DBD::ADO.
> But you don't need
> to load it -- DBI will load it for you.
>
> use DBI;
> # DBI automatically loads ADO
> my $dbh = DBI->connect('dbi:ADO:...',...);
>
> -----Original Message-----
> From: Patrix Diradja
> [mailto:patrixdiradja@yahoo.co.id]
> Sent: Thursday, February 08, 2007 10:54 AM
> To: dbi-users@perl.org
> Subject: Balasan: RE: Balasan: RE: Balasan: RE:
> can't execute "use
> $database"
>
> Dear Garrett.... it still doesn't work.
>
> Here is the error message:
> Can't locate DBI/ADO.pm in @INC (@INC contains:
> C:\Program
> Files\ActiveState Perl Dev Kit 6.0\lib\
> C:/Perl/site/lib C:/Perl/lib .)
> at cldump.pl line 8.
> BEGIN failed--compilation aborted at cldump.pl line
> 8.
>
> Please tell me furthermore.
>
> here is my code:
> #####
> use strict;
> use DBI::ADO;
> use Win32::OLE;
> use Win32::OLE::Const 'Microsoft ActiveX Data
> Objects';
> use warnings;
> my $uname="sa";
> my $pword="penguin";
> my $host="127.0.0.1";
> my @bd4l=("FinanCore");
> #if (@ARGV){
> #my @bd4l=@ARGV;
> #}else{
> #my @bd4l=("AprovaApp1");
> #}
> print "I am dumping... @bd4l\n";
> foreach my $elemenbd4l(@bd4l){
> my $dsn = "Provider=SQLNCLI;"
> . "Server=$host;"
> . "Database=$elemenbd4l;";
> my $dbh1 = DBI->connect("dbi:ADO:$dsn", $uname,
> $pword) or die
> $DBI::errstr;
>
> ####
>
> "Garrett, Philip (MAN-Corporate)"
> wrote:
> Patrix Diradja wrote:
> > Yeah, that's the problem Garrett.
> >
> > I usually use that way to connect to ms msql.
> >
> > But now, I want that my perl code can work with
> several databases.
> > So I need somewhat like the Connection String
> which I can modify
> > (forming string) and than just does
> "$dbh->connect(<> for me>>)". and
> does "$dbh->close" before doing again connect to
> > another database ($dbh->connect).
>
> Ok, try this: (found on www.connectionstrings.com)
>
> my $connstr = "Provider=SQLNCLI;"
> . "Server=$server;"
> . "Database=$database;";
>
> my $dbh =
> DBI->connect("dbi:ADO:$connstr",$user,$pass)
> || die $DBI::errstr;
>
> If you are using SQL Server 2005 Express, you'll
> need to add \EXPRESS
> after the server name like this:
> "Server=$server\\EXPRESS;"
>
> Philip
>
>
>
>
>
> ---------------------------------
> Kunjungi halaman depan Yahoo! Indonesia yang baru!
>







________________________________________________________
Sekarang dengan penyimpanan 1GB
http://id.mail.yahoo.com/

RE: Balasan: RE: Balasan: RE: Balasan: RE: Balasan: RE: can"t execute "use $database"

am 02.03.2007 16:14:24 von Philip.Garrett

Patrix Diradja wrote:
>=20
> Well, I thank you so much for your help. Your thread
> solved my problem.

Glad to hear it.

> Could you tell me which mailing-list for Perl/Tk what
> still active? I found a Perl/Tk mailing-list in
> yahoogroups and joined it. But the mail-list only
> content dirty disgusting porno everyday. Meine
> Guete....

The README for Perl/Tk suggests news:comp.lang.perl.tk
(http://groups.google.com/group/comp.lang.perl.tk/topics) or the
ptk@lists.stanford.edu mailing list.

- Philip