Home > Software engineering >  For help always convert a parameter from 4 'char [260]' to 'LPCTSTR'
For help always convert a parameter from 4 'char [260]' to 'LPCTSTR'

Time:09-30

CDatabase db.
Char DB [MAX_PATH];
Sprintf (DB, "ODBC; DSN=User_odbc; UID=", "the PWD=" "");
//LPCTSTR ch=(LPCTSTR) DB [MAX_PATH];
//db. The Open (NULL, FALSE, FALSE, ch);
The db. The Open (NULL, FALSE, FALSE, db);
//db. The Open (NULL, false, false, "ODBC; UID=""; The PWD="" ", true);

Error 'CDatabase: : Open: always convert a parameter from 4' char [260] 'to' LPCTSTR '

Could you tell me how to change this??????? Using VS2005 compiled the MFC project to connect to the database ACCESS code
Want to use the Unicode character set in, but don't know how to change? For help

CodePudding user response:

Using cstrings

Cstrings strDB (_T (" ODBC; DSN=User_odbc; UID=", "the PWD=" ""));
The db. The Open (NULL, FALSE, FALSE, strDB);

CodePudding user response:


Cstrings strDB (_T (" ODBC; DSN=User_odbc; UID=", "the PWD=" ""));

Mistake 3 error C2308: concatenating mismatched strings

Hello tried and prompted such a mistake

CodePudding user response:

This you want to escape, the string contains double quotes

Cstrings strDB (_T (" ODBC; DSN=User_odbc; UID=\ \ "", the PWD=" \ ""));

CodePudding user response:

Ok thank you very much
  • Related