Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

229 lines
5.0 KiB

  1. <%
  2. function GetDBConnection ( szConnectionString )
  3. {
  4. try
  5. {
  6. var g_DBConn = new ActiveXObject( "ADODB.Connection" );
  7. g_DBConn.CommandTimeout=240;
  8. g_DBConn.ConnectionTimeout = 235;
  9. try
  10. {
  11. g_DBConn.Open( szConnectionString );
  12. }
  13. catch( err )
  14. {
  15. return false;
  16. }
  17. }
  18. catch ( err )
  19. {
  20. return false;
  21. }
  22. return g_DBConn;
  23. }
  24. function ExecuteSP( Query, SP )
  25. {
  26. if( typeof( g_DBConn ) == "undefined" )
  27. g_DBConn = GetDBConnection( Application("CRASHDB3" ) )
  28. else if ( g_DBConn == null )
  29. g_DBConn = GetDBConnection( Application("CRASHDB3" ) )
  30. try
  31. {
  32. var rsRecordSet = g_DBConn.Execute( Query )
  33. return rsRecordSet
  34. }
  35. catch ( err )
  36. {
  37. Response.Write( "Could not execute " + SP + "(...)<BR>" )
  38. Response.Write( "Query: " + Query + "<BR>" )
  39. Response.Write( "[" + err.number + "] " + err.description )
  40. Response.End
  41. }
  42. }
  43. //set this to 1 for a debug build or true
  44. var DebugBuild = 1
  45. var DataSource = "test"
  46. /*
  47. //Set this for the DB access: (case sensitive)
  48. // test -bsod_db1
  49. // live -tkwucdsqla01
  50. // replicated -Replicated Data
  51. // or use the constants below
  52. var TEST = new String("test")
  53. var LIVE = new String("live")
  54. var REPLICATED = new String("replicated")
  55. var DataSource = REPLICATED.toString()
  56. if ( String(Application("DataSource")) == "undefined" )
  57. Application("DataSource") = DataSource //.toString()
  58. if ( DataSource != Application("DataSource") )
  59. {
  60. DataSource = Application("DataSource")
  61. }
  62. // WARNING: KLUDGE (a-mattk)
  63. DataSource = TEST.toString()
  64. if ( DebugBuild == 0 )
  65. {
  66. if ( Application("DebugBuild") == 1 )
  67. DebugBuild = 1
  68. else
  69. DebugBuild = 0
  70. }
  71. if ( DataSource == TEST )
  72. {
  73. var g_DBConnStrings = {
  74. //"DBGPORTAL" : "Driver=SQL Server;Server=scpsd;uid=sa;pwd=GoWin;DATABASE=dbgportal"
  75. //these are for test database
  76. //"SEP_DB" : "Driver=SQL Server;Server=bsod_db1;uid=sa;pwd=bsoddb1!;DATABASE=Solutions3",
  77. "SEP_DB" : "Driver=SQL Server;Server=redbgitsql13;uid=newsa;pwd=81574113;DATABASE=Solutions3",
  78. "CRASHDB" : "Driver=SQL Server;Server=redbgitsql13;uid=newsa;pwd=81574113;DATABASE=crashdb3",
  79. "TKOFF" : "Driver=SQL Server;Server=TKOFFDWSQL02;DATABASE=DWInternal;uid=dwsqlrw;pwd=am12Bzqt"
  80. }
  81. //Response.Write("<H3>Debug Build</H3>Utilizing BSOD_DB1 Test Database: <BR>")
  82. }
  83. else if ( DataSource == REPLICATED )
  84. {
  85. var g_DBConnStrings = {
  86. //these are for replicated data
  87. "SEP_DB" : "Driver=SQL Server;Server=TKWUCDSQLA02;uid=dbgportal;pwd=GoWin;DATABASE=Solutions",
  88. "CRASHDB" : "Driver=SQL Server;Server=TKWUCDSQLA02;uid=dbgportal;pwd=GoWin;DATABASE=crashdb2",
  89. "TKOFF" : "Driver=SQL Server;Server=TKOFFDWSQL02;DATABASE=DWInternal;uid=dwsqlrw;pwd=am12Bzqt"
  90. }
  91. //Response.Write("Utilizing Replicated Data Test Database: <BR>")
  92. }
  93. else if ( DataSource == LIVE )
  94. {
  95. var g_DBConnStrings = {
  96. //these are for the live database
  97. "SEP_DB" : "Driver=SQL Server;Server=tkwucdsqla01;uid=PublicWeb2;pwd=GoWin;DATABASE=Solutions",
  98. "CRASHDB" : "Driver=SQL Server;Server=tkwucdsqla01;uid=PublicWeb2;pwd=GoWin;DATABASE=crashdb2",
  99. "TKOFF" : "Driver=SQL Server;Server=TKOFFDWSQL02;DATABASE=DWLive;uid=dwsqlrw;pwd=am12Bzqt"
  100. }
  101. Response.Write("<H3>Utilizing Live Database: </H3>Be prepared for slower execution<BR>")
  102. }
  103. if( DebugBuild )
  104. var SEP_SolutionURL = "http://ocatest/resredir.asp?state=0&SID="
  105. else
  106. var SEP_SolutionURL = "http://ocatest/resredir.asp?state=0&SID="
  107. //Response.Write("Utilizing CrashDB2 Test Database: <BR>")
  108. //Response.Write("Utilizing BSOD_DB1 Test Database: <BR>")
  109. //Response.Write("Utilizing Replicated Data Test Database: <BR>")
  110. var g_DBConn = null
  111. function DB_GetConnectionObject( db )
  112. {
  113. var objDBConnection
  114. var e
  115. try
  116. {
  117. if ( g_DBConnStrings[db] )
  118. {
  119. try
  120. {
  121. g_DBConn = new ActiveXObject( "ADODB.Connection" )
  122. g_DBConn.CommandTimeout=5
  123. g_DBConn.ConnectionTimeout = 5
  124. g_DBConn.Open( g_DBConnStrings[db] )
  125. Response.Write("Database Opened successfully: " + db + "<BR>")
  126. }
  127. catch(e)
  128. {
  129. Response.Write ("The database connection could not be opened: <BR>Reason: " + e.description )
  130. }
  131. }
  132. else
  133. {
  134. Response.Write ( "The Database connection string specified could not be opened: " )
  135. }
  136. }
  137. catch ( e )
  138. {
  139. throw e
  140. }
  141. }
  142. function DB_CreateConnectionObject( db )
  143. {
  144. var objDBConnection
  145. var tmpDBConn
  146. var e
  147. try
  148. {
  149. if ( g_DBConnStrings[db] )
  150. {
  151. try
  152. {
  153. tmpDBConn = new ActiveXObject( "ADODB.Connection" )
  154. tmpDBConn.CommandTimeout=600
  155. tmpDBConn.ConnectionTimeout = 600
  156. tmpDBConn.Open( g_DBConnStrings[db] )
  157. }
  158. catch(e)
  159. {
  160. Response.Write ("The database connection could not be opened: <BR>Reason: " + e.description )
  161. }
  162. }
  163. else
  164. {
  165. Response.Write ( "The Database connection string specified could not be opened: " )
  166. }
  167. }
  168. catch ( e )
  169. {
  170. throw e
  171. }
  172. return tmpDBConn
  173. }
  174. */
  175. %>