Home > Software engineering >  What a great god help me look at the problems in the MFC development?
What a great god help me look at the problems in the MFC development?

Time:09-22

CodePudding user response:

Code? ZSZS

CodePudding user response:

Connection failed to Open, first to see if the Connection string is write wrong,

CodePudding user response:

Before using the query analyzer connected to SQL Server, after having confirmed to use the program links,

CodePudding user response:

Do not have permission to access SQL server

CodePudding user response:

MFC database connection?

CodePudding user response:

Database connection fails

CodePudding user response:

Is equivalent to not find database server, the server PC firewall to shut down, and some parameters to set,

CodePudding user response:

Try using odbc

CodePudding user response:

1, first determine the target SQL Server can connect
2, confirm the parameter is set if there is a problem

//create 
This - & gt; M_pConnection. CreateInstance (_T (" ADODB. Connection "));//this - & gt; M_pConnection. CreateInstance (__uuidof (Connection));

//
CsConnection. The Format (_T (" Provider=SQLOLEDB; The Network Library=DBMSSOCN; The Data Source=% s. Initial Catalog=% s. User ID=% s. Password=% s "),
Wcp_Server_Name wcp_DB_Name, wcp_User_Name wcp_Password);

_variant_t BCNSTR=_variant_t (csConnection);

_variant_t bunstr=_variant_t (wcp_User_Name);

_variant_t BPWDSTR=_variant_t (wcp_Password);

//connection timeout setting
This - & gt; M_pConnection - & gt; ConnectionTimeout=i_Connect_Timeout;

//the open
This - & gt; M_pConnection - & gt; Open (_bstr_t (BCNSTR), _bstr_t (bunstr), _bstr_t (BPWDSTR), adModeUnknown);

CodePudding user response:

 
//initialize the OLE/COM library environment
: : CoInitialize (NULL);
Retrieves the hr=m_pConnection. CreateInstance (" ADODB. Connection ");
Test for a successful hr

CodePudding user response:

Connect to the database failed problem also many, elimination process

CodePudding user response:

Can't find the SQL or the permission was not enough
  • Related