Home > Software engineering >  Using ADO to connect to the database
Using ADO to connect to the database

Time:10-21

HRESULT nRet=m_pConn. CreateInstance (__uuidof (Connection));

If (FAILED (nRet))
{
_com_error e (nRet);
AfxMessageBox (e.E rrorMessage ());
return FALSE;
}

Cstrings strConn=
(" the Provider=SQLOLEDB. 1; Persist Security Info=False;"
"User ID=so; Password=12345678;"
"Initial Catalog=time; The Data Source=1 XX. XX. XX. XX." );

nRet=m_pConn - & gt; Open ((_bstr_t) strConn, ""," ", NULL);//in this step will make a mistake

If (FAILED (nRet))
{
_com_error e (nRet);
AfxMessageBox (e.E rrorMessage ());//show "unspecified error"
return FALSE;
}

Native IP database using SQL Server Management Studio is accessible, but not a use ADO,

the same code, just change the IP, access to other IP database,
See the account access these are right, firewall also try a modified IP can't,
Ask colleagues for the first time see, the great god knows what reason be?

CodePudding user response:

Is not a great god, "the same code, just change the IP, access to other IP database can be," that's code for, the remaining problems setting up the database software, try other computer using SQL Server Management Studio ok for database connection you not on the road, not heavy,

CodePudding user response:

reference 1st floor cvbtvbwu response:
is not a great god, "the same code, just change the IP, access to other IP database can be," that's code for, the remaining problems setting up the database software, try other computer using SQL Server Management Studio connect you ok for the database is not on the road, not heavy,


In other computer I tried, it is possible, indeed as expected or database have problems when yao=,=

CodePudding user response:

Test the connection string can use ADO assistant,

CodePudding user response:

reference zyq5945 reply: 3/f
can use ADO assistant test connection string,


Thank you, before tried, no problem statement, other IP is can even,

CodePudding user response:

"The Provider=SQLOLEDB; Server=XXX, XXX, XXX. Xx, xx. The Database=??? ; UID=??? ; The PWD=??????? ")
  • Related