Incognito has asked for the wisdom of the Perl Monks concerning the following question:
When using a provider string with a local SQL Server user, say "MyName" with a password "MyPassword", a typical string would look like this:
use Win32::OLE; use Win32::OLE::Const 'Microsoft ActiveX Data Objects'; $strProvider = 'Provider=sqloledb;Data Source=MyServerName;Initial Cat +alog=MyCatalog;'; $strProvider .= 'User Id=MyName;Password=MyPassword'; $strQuery = "SELECT 1 AS SystemName"; $objConn = CreateObject Win32::OLE "ADODB.Connection"; $objConn->Open($strProvider); $objRS = $objConn->Execute($strQuery); if ($objRS) { while ( !$objRS->EOF ) { my($SystemName) = ( $objRS->Fields('SystemName')->value ); print "SystemName: ", $SystemName, "\n"; $objRS->MoveNext; } } else { print "This doesn't work!!!\n"; }
This code should print a simple "1" as data... and this does indeed work. Now, if we go and add a Domain Name to the User, things don't work, and I can't figure out why... I've tried many different variations with the "/" (I've done double backslash, double forward slash, singles, even quads, but none of them work).
This is what the provider string would look like:
$strProvider = 'Provider=sqloledb;Data Source=MyServerName;Initial Cat +alog=MyCatalog;'; $strProvider .= 'User Id=MYMACHINE\MyName;Password=MyPassword';
This doesn't work, and it's really bugging me... Anyone have any ideas as to how to get a user that has a domain name to connect to a SQL Server?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How can I add a Domain into the UserName of a Provider String using Win32::OLE
by NetWallah (Canon) on May 14, 2004 at 21:47 UTC | |
by Incognito (Pilgrim) on May 14, 2004 at 22:14 UTC | |
by NetWallah (Canon) on May 15, 2004 at 06:38 UTC | |
|
Re: How can I add a Domain into the UserName of a Provider String using Win32::OLE
by jdporter (Paladin) on May 14, 2004 at 20:30 UTC |