You are not logged in.
Hello
I use yours MSSQL OLE DB driver. Only driver i.e. ISqlDBRows and ISqlDBStatement, not ORM. But sometimes I need to get raw MS SQL column types. I parsed your code until late at night and i created the following function (i still have a little headache from it):
type
TSqlDBOleDBStatementHack = class(TSqlDBOleDBStatement);
TSqlDBOleDBConnectionHack = class(TSqlDBOleDBConnection);
function TmORMotOLEDBBaseAdapter.GetRawColTypes(const aRS: ISqlDBRows): TArray<WORD>;
var
DBStat: TSqlDBStatement;
DBOLEStat: TSqlDBOleDBStatementHack;
Conn: TSqlDBConnection;
Cols, nfo: PDBColumnInfo;
nCols: PtrUInt;
ColsNames: PWideChar;
i: Integer;
begin
DBStat := aRS.Instance;
if DBStat is TSqlDBOleDBStatement then
begin
SetLength(Result,aRS.ColumnCount);
DBOLEStat := TSqlDBOleDBStatementHack(TSqlDBOleDBStatement(DBStat));
TSqlDBOleDBConnectionHack(DBOLEStat.OleDBConnection).OleDBCheck(DBStat,(DBOLEStat.fRowSet as IColumnsInfo).GetColumnInfo(nCols, Cols, ColsNames));
try
nfo := Cols;
for i := 1 to nCols do
begin
Result[i-1] := nfo^.wType;
inc(nfo);
end;
finally
TSqlDBOleDBConnectionHack(DBOLEStat.OleDBConnection).fMalloc.Free(Cols);
TSqlDBOleDBConnectionHack(DBOLEStat.OleDBConnection).fMalloc.Free(ColsNames);
end;
end;
end;
This is the right and best way to achieve the right result?
Daniel Andrascik
Offline
I have just enhanced TSqlDBOleDBStatement to let TSqlDBColumnProperty.ColumnValueDBType store the raw DBTYPE value.
I guess this is the more convenient and safe way of getting this information.
Check https://github.com/synopse/mORMot2/comm … 6a9dc1f53d
and https://github.com/synopse/mORMot2/commit/cda6b213d6
Offline
Great work...
Offline