Home > Software engineering >  The error C2440: "=" : from "BSTR" into a "long"
The error C2440: "=" : from "BSTR" into a "long"

Time:09-20

  , as shown here I use ado to read access database, in which the first column should be set into long type automatic numbering, but in MFC applications cannot translate into" BSTR "type, how to change? inquire

CodePudding user response:

Id=atoi ((char *) (_bstr_t) rs - & gt; GetCollect (colname))
Under the corresponding modification

CodePudding user response:

The data is defined as cstrings

CodePudding user response:

refer to the second floor zgl7903 response:
data defined as cstrings
I can't the teacher, the long integer variables is data corresponding to the database "serial number" that a column, the column is the automatic numbering, the corresponding is long, if not directly to cstrings,

CodePudding user response:

reference 1st floor smwhotjay response:
id=atoi ((char *) (_bstr_t) rs - & gt; GetCollect (colname))
Under the corresponding modify
that's not much of a better teacher

CodePudding user response:

# if defined (WIN32) & amp; & ! Defined (OLE2ANSI)
Typedef WCHAR OLECHAR;
# the else
Typedef char OLECHAR;
# endif
Typedef OLECHAR * BSTR;

The typedef char * BSTR
Pointer is converted into a long
BSTR (long)

CodePudding user response:

Union members of the selection error, bstrVal long instead

CodePudding user response:

 
M_list. InsertItem (0, "");
Cstrings data;
data=https://bbs.csdn.net/topics/(char *) (_bstr_t) rs -> GetCollect (" serial number ");
M_list. SetItemText (0, 0, data);

CodePudding user response:

Visual inspection result of your column is the VARIANT types, then you directly take his long don't have to, why don't want to pick up the bstrVal?
Take long, of course, also cannot be directly assigned to cstrings, want to format the,
Data=https://bbs.csdn.net/topics/CString.format (_T (" % d "), a (long) CMD. M_pRecordset - & gt; GetCollect (" serial number "));
Of course, there are may not be a ULONG type, what is actually the VARIANT type, can know from vt field,


  • Related