Browse Source

* Patch from Ludo Brands to implement InstanceName (Bug ID 24635)

git-svn-id: trunk@24932 -
michael 12 years ago
parent
commit
2b6f33711b
2 changed files with 23 additions and 5 deletions
  1. 17 4
      packages/dblib/src/dblib.pp
  2. 6 1
      packages/fcl-db/src/sqldb/mssql/mssqlconn.pp

+ 17 - 4
packages/dblib/src/dblib.pp

@@ -69,19 +69,32 @@ const
   DBTDS_72     = 10; // Microsoft SQL Server 2005
   DBTDS_72     = 10; // Microsoft SQL Server 2005
   DBTDS_73     = 11; // Microsoft SQL Server 2008
   DBTDS_73     = 11; // Microsoft SQL Server 2008
 
 
-  //from sqlfront.h:
+  //from sqlfront.h ,   sybdb.h for freetds
   DBSETHOST=1;
   DBSETHOST=1;
   DBSETUSER=2;
   DBSETUSER=2;
   DBSETPWD=3;
   DBSETPWD=3;
-  DBSETAPP=4;
+  DBSETAPP={$IFDEF freetds}5{$ELSE}4{$ENDIF};
+  {$IFDEF freetds}
+  DBSETHID=     4;
+  DBSETBCP=	6;
+  DBSETNATLANG=	7;
+  DBSETNOSHORT=	8;
+  DBSETHIER=	9;
+  DBSETCHARSET=	10;
+  DBSETPACKET=	11;
+  DBSETENCRYPT=	12;
+  DBSETLABELED=	13;
+  DBSETDBNAME=	14;
+   {$ELSE}
   DBSETID=5;
   DBSETID=5;
   DBSETLANG=6;
   DBSETLANG=6;
   DBSETSECURE=7;
   DBSETSECURE=7;
+  DBSET_LOGINTIME=10;
+  DBSETFALLBACK=12;
+  {$ENDIF}
   //These two are defined by Microsoft for dbsetlversion():
   //These two are defined by Microsoft for dbsetlversion():
   DBVER42={$IFDEF freetds}DBVERSION_42{$ELSE}8{$ENDIF};
   DBVER42={$IFDEF freetds}DBVERSION_42{$ELSE}8{$ENDIF};
   DBVER60={$IFDEF freetds}DBVERSION_71{$ELSE}9{$ENDIF};
   DBVER60={$IFDEF freetds}DBVERSION_71{$ELSE}9{$ENDIF};
-  DBSET_LOGINTIME=10;
-  DBSETFALLBACK=12;
   //dboptions:
   //dboptions:
   DBNOAUTOFREE = {$IFDEF freetds}15{$ELSE}8{$ENDIF};
   DBNOAUTOFREE = {$IFDEF freetds}15{$ELSE}8{$ENDIF};
   DBTEXTLIMIT  = {$IFDEF freetds}7{$ELSE}4{$ENDIF};
   DBTEXTLIMIT  = {$IFDEF freetds}7{$ELSE}4{$ENDIF};

+ 6 - 1
packages/fcl-db/src/sqldb/mssql/mssqlconn.pp

@@ -30,7 +30,8 @@
       CharSet - if you use Microsoft DB-Lib and set to 'UTF-8' then char/varchar fields will be UTF8Encoded/Decoded
       CharSet - if you use Microsoft DB-Lib and set to 'UTF-8' then char/varchar fields will be UTF8Encoded/Decoded
                 if you use FreeTDS DB-Lib then you must compile with iconv support (requires libiconv2.dll) or cast char/varchar to nchar/nvarchar in SELECTs
                 if you use FreeTDS DB-Lib then you must compile with iconv support (requires libiconv2.dll) or cast char/varchar to nchar/nvarchar in SELECTs
       Params - "AutoCommit=true" - if you don't want explicitly commit/rollback transactions
       Params - "AutoCommit=true" - if you don't want explicitly commit/rollback transactions
-               "TextSize=16777216 - set maximum size of text/image data returned
+               "TextSize=16777216" - set maximum size of text/image data returned
+               "ApplicationName=YourAppName" Set the app name for the connection. MSSQL 2000 and higher only
 }
 }
 unit mssqlconn;
 unit mssqlconn;
 
 
@@ -193,6 +194,7 @@ const
   SBeginTransaction = 'BEGIN TRANSACTION';
   SBeginTransaction = 'BEGIN TRANSACTION';
   SAutoCommit = 'AUTOCOMMIT';
   SAutoCommit = 'AUTOCOMMIT';
   STextSize   = 'TEXTSIZE';
   STextSize   = 'TEXTSIZE';
+  SAppName   = 'APPLICATIONNAME';
 
 
 
 
 var
 var
@@ -428,6 +430,9 @@ begin
   else
   else
     dbsetlcharset(FDBLogin, PChar(CharSet));
     dbsetlcharset(FDBLogin, PChar(CharSet));
 
 
+  if Params.IndexOfName(SAppName) <> -1 then
+    dbsetlname(FDBLogin, PChar(Params.Values[SAppName]), DBSETAPP);
+
   //dbsetlname(FDBLogin, PChar(TIMEOUT_IGNORE), DBSET_LOGINTIME);
   //dbsetlname(FDBLogin, PChar(TIMEOUT_IGNORE), DBSET_LOGINTIME);
   dbsetlogintime(10);
   dbsetlogintime(10);