MS SQL Server connection component (TMSSQLConnection class)
Original Reporter info from Mantis: lacak @lacak.sk
-
Reporter name: LacaK
Original Reporter info from Mantis: lacak @lacak.sk
- Reporter name: LacaK
Description:
descendant of TSQLConnection class, which uses either Microsoft Client DB-Library (ntwdblib.dll)
or db-lib (dblib.dll) from FreeTDS project (multiplatform) as native client library.
Tested only under Windows, so some work for *nix must be done.
Files: mssqlconn.pp - TMSSQLConnection class
dblib.pp - DB-Library API (static linkage either to ntwdblib.dll or dblib.dll)
dblib.dll - compiled FreeTDS db-lib API (AFAIK FreeTDS project does not release precompiled libraries, so I used MS Visual C++ 2005 Express (free) to build it)
Some "optimalization" suggestions:
- add to TParams class method, which replaces parameter placeholders in parsed SQL (produced by TParams.ParseSQL)
1,..,
n with values of parameters
There is in mssqlconn.pp method ReplaceParams with same source code (which replaces1,..,
n with actual parameter values formated using GetAsSQLText) as in mysqlconn.pp and pqconnection.pp
So if we move this method to dsparams.inc (or in sqldb.pp) and make it global, we should get rid of "duplicated code".
2. add function/method to determine storage size of individual field types
There is private method TCustomBufDataset.GetFieldSize in bufdataset.pas which do it (just like property DataSize of TField)
If we move this method to fields.inc into TFieldDef class and make it public (or implement property TFieldDef.DataSize read GetFieldSize),
then we will have in one place "size handling" and if some datatype storage will be changed or added, then only this unit will be modified
and we can get rid of "repeated" code (in TSQLConnection descendants) like this (to determine fields storage size into record buffer):
case FieldDef.DataType of
ftString:= destlen:=FieldDef.Size+1;
ftSmallint: destlen:=sizeof(smallint);
ftInteger: destlen:=sizeof(integer);
ftLargeInt: destlen:=sizeof(int64);
ftCurrency,ftFloat: destlen:=sizeof(double);
ftBoolean: destlen:=sizeof(wordbool);
...etc.
end;
Mantis conversion info:
- Mantis ID: 17303
- Version: 2.5.1
- Fixed in version: 3.0.0
- Fixed in revision: 20522 (#5331e66a)
- Monitored by: » @mdbs99 (Marcos Douglas), » BigChimp (Reinier Olislagers), » jixian.yang (yang jixian), » dioannidis (Dimitrios Chr. Ioannidis), » @PascalDragon (Sven Barth)
- Target version: 3.0.0