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



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)" <Philip.Garrett@xxxxxxxxxxx> 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!

Relevant Pages

  • RE: Logging in in background
    ... wold take all kinds of modifictions as I'd need to be checking that each SQL ... my database and all have connection strings associated with them. ... I suspect that there is also an issue on the SQL Server side as I keep ...
    (microsoft.public.access.modulesdaovba)
  • Re: User not associated with trusted SQL Server connection
    ... > using the osql utility. ... > associated with a trusted SQL Server connection. ... > database or is it just for that instance. ...
    (microsoft.public.sqlserver.security)
  • RE: Manipulating MS Access records with excel VBA + ADO
    ... While I cannot see how a working example of a connection to a database is ... Select the control button view dataor edit query. ... Look for SQL button to get the SQL ...
    (microsoft.public.excel.programming)
  • Re: MySQL on Win 98
    ... Hitting the Verify Connection button in VFP produced a C5 crash. ... With a "System" DSN configured the same way (except for the Data ... Incorrect database name". ...
    (microsoft.public.fox.programmer.exchange)
  • Re: Is it just me or are there BIG problems with SQLCE 3.0?
    ... has been done with parameterised SQL, ... bit of code into my test which closes and reopens the database ... opening and closing the DB connection is not a good idea. ... // Display all error messages ...
    (microsoft.public.sqlserver.ce)

Loading