Home > Software engineering >  C ADO connection SQL2008 very slow problem
C ADO connection SQL2008 very slow problem

Time:10-15

Void ADOConn: : OnInitADOConn ()
{
//initialize the OLE/COM library environment
: : CoInitialize (NULL);
Try
{
//create a connection object
//equivalent to the following statements: m_pConnection CreateInstance (" ADODB. Connection ");
M_pConnection. CreateInstance (__uuidof (Connection));

//set the connection string
The Provider=_bstr_t strConnect="SQLOLEDB. 1; Integrated Security=SSPI; \
Persist Security Info=False; Initial Catalog=WenDGL; The Data Source=. \ \ ";
//the SERVER and the UID and PWD set according to the actual situation to set the
M_pConnection - & gt; Open (strConnect, ""," ", adModeUnknown);
}
//the catching
Catch _com_error (e)
{
//display an error message
AfxMessageBox (e.D escription ());
}
}


Connection part of the code, the code itself has no problems, the connection can be successful, insert, query and so on, there is no problem next steps, is to run slow
After debugging found m_pConnection - & gt; Open (strConnect, ""," ", adModeUnknown); Running very slow, such as more than 10 seconds to respond
Using SQL server 2008 and vs2010 MFC

CodePudding user response:

Using XP provides ADO

CodePudding user response:

I put the msado15. DLL file into the xp version 2.81, useless, or slowly

CodePudding user response:

If there is something wrong with the connection string parameters, can use ADO assistants under test,

CodePudding user response:

reference zyq5945 reply: 3/f
if there is something wrong with the connection string parameters, can use ADO assistant under test,



Ok, thank you, is the connection string parameters have a problem, I use ADO assistant to regenerate the connection code

CodePudding user response:

The Provider=SQLNCLI10.1; Integrated Security=SSPI; Persist Security Info=False; User ID=""; Initial Catalog=dname; Data Source=. Initial File Name=""; Server SPNS=""

Correct connection, please don't use the OLEDB to 2008 database.
  • Related