|
-
November 28th, 2003, 12:50 PM
#1
SQLDMO Error Connecting
I am trying to connect to a SQL Server 2000 database using SQLDMO. The following code returns "FAILED" while it's equivalent in Visual Basic is able to connect just fine:
if FAILED(CoInitialize(NULL))
return FALSE;
LPSQLDMOSERVER2 m_pSQLServer = NULL;
HRESULT hr = CoCreateInstance(CLSID_SQLDMOServer2, NULL, CLSCTX_INPROC_SERVER, IID_ISQLDMOServer2, (LPVOID*)&m_pSQLServer);
if FAILED(hr)
return FALSE;
if (m_pSQLServer == NULL)
return FALSE;
m_pSQLServer->SetLoginTimeout(10);
hr = m_pSQLServer->SetLoginSecure(TRUE);
if FAILED(hr) return FALSE;
hr = m_pSQLServer->Connect((SQLDMO_LPCSTR)"RAY");
if FAILED(hr)
AfxMessageBox("FAILED");
else
AfxMessageBox("OK");
if (m_pSQLServer != NULL)
m_pSQLServer->Release();
CoUninitialize();
Can anyone tell me why this works in VB, but not C++?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|