this time the variable is mainly for MFC's Cstring type of variable (front VC link Access database insert variable to table)Ideas1 Convert CString type to string2 string to char array 3 sprintf Write array
string to char Array function
char* Zhuanhuan (std::string src) {char *dst = new char[255];int i; int j=src.length (); for (I=0;i <src.length (); i++) dst[ I]=src[i]; Dst[i] = ' + '; return DST;}
Code reference:
OpenAccess (); CString Cmbparam = L "Selfimprovement"; std::string a1= (CT2A) (Cmbparam.getbuffer ()); char buff[256] = {0}; sprintf ( Buff, "select * from tb_yctype where ycname = '%s ' ORDER by yctype Desc", Zhuanhuan (A1)); M_precordset = M_pconnection->e Xecute (Buff, &recordsaffected, adCmdText);
This is a practical way to do it! Other methods I do not use, but also welcome to have a good way to communicate!
VC Access ADO where variable