Home > Back-end >  C to connect SQL server2008, check without error, solve, thank you
C to connect SQL server2008, check without error, solve, thank you

Time:10-11




Void ADOConn: : OnInitADOConn ()
{
: : CoInitialize (NULL);


Try
{
Retrieves the hr;
Hr=m_pConnection. CreateInstance (" ADODB. Connection ");
If (SUCCEEDED (hr))
Hr=m_pConnection - & gt; Open (" provider=SQLOLEDB; Data Source=IDEA - PC \ SQLEXPRESS; Initial catalog=eye electronic medical records system; Integrated Security=SSPI;" , ""," ", adModeUnknown);

}
Catch _com_error (e)
{

E.D escription ();


}
}

CodePudding user response:

If nothing else, at least this line:
Hr=m_pConnection - & gt; Open (" provider=SQLOLEDB; Data Source=IDEA - PC \ SQLEXPRESS; Initial catalog=eye electronic medical records system; Integrated Security=SSPI;" , ""," ", adModeUnknown);

Should be changed to:
 hr=m_pConnection - & gt; Open (" provider=SQLOLEDB; Data Source=IDEA - PC \ \ SQLEXPRESS; Initial catalog=eye electronic medical records system; Integrated Security=SSPI;" , ""," ", adModeUnknown); 

CodePudding user response:

Check with local businesses, the manager can not be connected in environment can show no problem, then take a look at your application

CodePudding user response:

The instance name in Chinese... For the first time to see so,
About the database connection
http://www.connectionstrings.com/
This website is very full, according to taking it