Home All Groups Group Topic Archive Search About

Help with SQLServer2.Connect()

Author
7 Sep 2006 7:04 PM
SteveM
Hi,

The short version of what I am needing is this:
I need a way to code (In c# and preferably in SQL-DMO) a connection to
a named instance
of SQL Server 2000 that is running on a machine with other named
instances. The named instance in particular in this case is G3. There
is another part that may make this more complicated... G3 is running
specifically on port 1032 and only on that (due to UDP 1434
restrictions on our firewalls).

Now for the longer version:


I have this bit of code in a much larger program


                    SQLServer2Class myServer = new SQLServer2Class();
                    myServer.LoginSecure = true;
                    myServer.Connect("(local)\\G3", null, null);

It fails with the following errors:

Unhandled Exception: System.Runtime.InteropServices.COMException
(0x80040000): [Microsoft][ODBC SQL Server Driver][
DBNETLIB]SQL Server does not exist or access denied.
[Microsoft][ODBC SQL Server Driver][DBNETLIB]ConnectionOpen
(Connect()).
   at SQLDMO.SQLServer2Class.Connect(Object ServerName, Object Login,
Object Password)
   at BackUp.BackUpControl.backUpRegularDatabases()
   at BackUp.DBBackup.Main(String[] args)

I figure that either
"(local)\\G3" is invalid in which case I need to understand what the
correct syntax is for
working with a named instances on the same physical server
or
The problem is because we had to statically assign a specific TCP\IP
port number for the new instance (do to firewall restrictions)

So the bottom line is... How do I write a piece of connection code
(prefer SQL-DMO) to connect up to a named instance on a machine (local
to where this script is running) that is connecting via a specific port
(No UDP 1434)

Any Help will be really really really appreciated ;-)

Thanks
-Steve

AddThis Social Bookmark Button