Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Anders Altberg
  Where is Anders Altberg?
 Uppsala
 Sweden
 Anders Altberg
 To: Peter Wagner
  
 Limeira
 
 Peter Wagner
 Tags
Subject: RE: Problem with SQL-DMO in Connection
Thread ID: 228442 Message ID: 228515 # Views: 2 # Ratings: 0
Version: Visual FoxPro 9 Category: Databases, Tables and SQL Server
Date: Tuesday, May 19, 2009 2:52:30 PM         
   


> Forget, I solved the problem.
>
> Hi, I'm trying to make a connection to SQL Server using SQL-DMO.
>
> The problem is how to do it passing parameters to establish the connection
> This sample here works..
> LOCAL cNome_banco_desejado, cSenha_conexao, cLogin
> cNome_banco_desejado = ALLTRIM(Config_Conexao.Banco)
> cLogin = ALLTRIM(Config_Conexao.uid)
> cPassword = ALLTRIM(Config_Conexao.senha)
>
> LOCAL oAppSQL AS SQLDMO.APPLICATION
> LOCAL oServer AS SQLDMO.SQLServer
> LOCAL oDatabase AS SQLDMO.DATABASE
> LOCAL oNames AS SQLDMO.NameList
> LOCAL oName AS Variant
>
> oAppSQL = CREATEOBJECT("SQLDMO.Application")
> oNames = oAppSQL.ListAvailableSQLServers()
> FOR EACH oName IN oNames
> oServer = CREATEOBJECT("SQLDmo.SqlServer")
> oServer.LoginSecure = .F. && not trusted
> oServer.Login = 'sa'
> oserver.Password = 'zqt389pl'
> oServer.CONNECT(oName)
> * oServer.CONNECT(oName,'sa', 'zqt389pl') && Conect to server (this also works)
>
> * my code here....
>
> oServer.DisConnect
> oServer = NULL
> ENDFOR
> oAppSQL.QUIT
> oAppSQL = NULL
>
> But when I try to establish the connection passing UserID and password to the same come I can't connect to the server?
> returns error:
> OLE IDispatch exception code 18456 from Microsoft SQL-DMO
> (ODBC SQLState: 28000): [Microsoft][ODBC SQL Server Driver]
> [SQL Server]Login failed for user ''sa''...
>
> Any idea why?
> I'm passing the same values to establish the connection...
>
> LOCAL cNome_banco_desejado, cSenha_conexao, cLogin
> cNome_banco_desejado = ALLTRIM(Config_Conexao.Banco)
> cLogin = "'sa'"
> cPassword = "'zqt389pl'"
>
> LOCAL oAppSQL AS SQLDMO.APPLICATION
> LOCAL oServer AS SQLDMO.SQLServer
> LOCAL oDatabase AS SQLDMO.DATABASE
> LOCAL oNames AS SQLDMO.NameList
> LOCAL oName AS Variant
>
> oAppSQL = CREATEOBJECT("SQLDMO.Application")
> oNames = oAppSQL.ListAvailableSQLServers()
> FOR EACH oName IN oNames
> oServer = CREATEOBJECT("SQLDmo.SqlServer")
> oServer.LoginSecure = .F. && not trusted
> oServer.Login = cLogin
> oserver.Password = cPassword
> oServer.CONNECT(oName) && <<== Error here
>
> * my code here....
>
> oServer.DisConnect
> oServer = NULL
> ENDFOR
> oAppSQL.QUIT
> oAppSQL = NULL
>
> TIA
> Peter



This link has more precide informatiuon about this particular error message: http://blogs.msdn.com/sql_protocols/archive/2006/02/21/536201.aspx
-Anders

ENTIRE THREAD

Problem with SQL-DMO in Connection Posted by Peter Wagner @ 5/19/2009 12:40:52 AM
RE: Problem with SQL-DMO in Connection Posted by Anders Altberg @ 5/19/2009 2:52:30 PM