This article wants to say how to get various types of values in the recordset. For example, if the database is defined in the database, what should we write when we get data? Here I provide some macro definitions, you can easily obtain data in the database as long as you insert these statements in stdafx.h or otherwise needed to use these macros. There is no relationship with the type of database.
#define createInstance (SP, RIID) {hResult_hr = sp.createInstance (__ uuidof (riid)); if (failed (_hr)) _com_issue_error (_hr);
This is used to create a database connection, Command, and records objects. Can call this:
CreateInstance (M_Piconnection, Connection);
#define rsitem (rs, x) rs-> Fields-> item [_variant_t (x)] -> value
#define Rsitem_BSTR (RS, X) (Rsitem (RS, X) .vt == VT_NULL) CSTRING (""): Rsitem (RS, X) .BSTRVAL
#define rsitem_double (rs, x) (Rsitem (RS, X) .vt == VT_NULL)? 0: Rsitem (RS, X) .dblval
#define rsitem_long (rs, x) (Rsitem (RS, X) .vt == VT_NULL)? 0: Rsitem (RS, X) .lval
#define rsitem_byte (rs, x) (RSITEM (RS, X) .vt == VT_NULL)? 0: Rsitem (RS, X) .bval
#define rsitem_date (rs, x) (RSITEM (RS, X) .vt == VT_NULL)? 0: Rsitem (rs, x) .date
#define Rsitem_Bool (RS, X) (Rsitem (RS, X) .vt == VT_NULL)? 0: Rsitem (RS, X) .boolval
#define Rsitem_Decimal (RS, X) (RSITEM (RS, X) .vt == VT_NULL)? 0.0: Rsitem (RS, X)
The above macros is to get data in the database, Double, integer, date, Boolean, and Numeric.
The calling routine is as follows:
sshipinfo.smmsiid = rsitem_bstr (Pirecordset, "MMSI_ID");
sshipinfo.scallsign = rsitem_bstr (Pirecordset, "Call_SIGN");
Sshipinfo.sshipname = rsitem_bstr (Pirecordset, "Name");
sshipinfo.fcog = rsitem_decimal (Pirecordset, "COG");
Sshipinfo.fsog = rsitem_decimal (Pirecordset, "SOG");
sshipinfo.wbreadth = rsitem_long (Pirecordset, "Width");
Sshipinfo.wlength = rsitem_long (pirecordset, "length"); sshipinfo.lalong.dlatitude = rsitem_decimal (Pirecordset, "LAT");
sshipinfo.latlong.dlongitude = rsitem_decimal (Pirecordset, "long");
sshipinfo.repttime = rsitem_date (Pirecordset, "Rept_Time");
Since the database call does not have a legend, there is no picture to be posted.