%@ LANGUAGE=VBScript LCID=1033 %> <% '********************************************************* ' @ Directives ' ' LCID ' English - United States '********************************************************* '********************************************************* ' Purpose: ' Security Requirements '********************************************************* Option Explicit ' For IIS 5.0 and later, the default value is True. Response.Buffer = True '********************************************************* ' If this page generates custom HTML for every request, ' you won't improve performace by setting CacheControl to ' public. The default is Private, which means that only ' private caches may cache this page - proxy servers won't ' cache it. '********************************************************* 'Response.CacheControl = "Public" ' Assure that both expression are numeric, because how ' expressions are compared, depends on their underlying ' subtype. Function CheckRange(Value, Min, Max) CheckRange = True : If (Value < Min) Or (Value > Max) Then CheckRange = False End Function Dim lngContentID On Error Resume Next lngContentID = CLng(Request.QueryString("content_id")) If Err.Number <> 0 Then lngContentID = -1 On Error GoTo 0 '********************************************************* ' The CLng function rounds the fractional part or a ' number. It returns 0 if expression is Empty. '********************************************************* If IsNumeric(lngContentID) = False Then lngContentID = -1 %> <% ' ADO Objects Dim conn Dim cmd Dim rs Set conn = Server.CreateObject("ADODB.Connection") '********************************************************* ' By default, CursorLocation property is set to the ' server-side cursor library. '********************************************************* ' This setting doesn't take effect until the next time you ' call BeginTrans method. 'conn.IsolationLevel ' Because we are only going to read data, set the Mode ' property to adModeRead. conn.Mode = adModeReadWrite ' Dynamic properties defined by the underlying data ' provider (SQLOLEDB). 'conn.Properties ' Opens the connection synchronously. conn.Open Application("CONN_STRING") ' Cancels execution of an asynchronous method call (Open ' Method). 'conn.Cancel 'conn.Error '********************************************************* ' Use the Command object to execute the stored procedure. '********************************************************* Set cmd = Server.CreateObject("ADODB.Command") cmd.ActiveConnection = conn '********************************************************* ' p_GetDocument ' ' None of the stored procedure arguments have a default ' value. ' ' doc_header_id ' ' Result Set ' ' doc_header_id ' content_category_id ' author_id ' title ' published ' exp_date ' public ' keywords ' description ' publisher ' language_id ' os_filename ' content ' dir ' dir_desc ' ' For more information, see the description of the columns ' in the modFile2DB.inc script. '********************************************************* cmd.CommandText = "p_GetDocument" cmd.CommandType = adCmdStoredProc ' Pass parameter names to the provider. 'cmd.NamedParameters = True '********************************************************* ' Whenever possible, avoid calling the Refresh method of ' the Parameters collection because this causes the client ' to make unnecessary trips to the server to retrieve ' information. '********************************************************* '********************************************************* ' Included in the parameters is the stored procedure's ' return value. '********************************************************* With cmd .Parameters.Append .CreateParameter("@doc_header_id", adInteger, , , lngContentID) End With ' Handle any run-time errors that the CreateParameter ' method might generate. If Err.Number <> 0 Then ReportError(conn) Set rs = Server.CreateObject("ADODB.Recordset") ' The default value is 1. 'rs.CacheSize = 1 '********************************************************* ' Open Method (ADO Recordset) ' ' CursorType ' The cursor type is set to adOpenKeyset because we ' have a large result set and need to select just one ' row. ' LockType ' The default value is adLockReadOnly. The table data ' can't be altered. ' Options ' Set the Options parameter only if the Source argument ' represents something other than a Command object. '********************************************************* '********************************************************* ' I can't change the CursorType. ' ' For more information, see the following KB article: ' ' Q188857 PRB: Use Open Method to Change CursorType and ' LockType '********************************************************* rs.Open cmd ', , adOpenStatic %> <% Dim intSavedCodePage : intSavedCodePage = Session.CodePage If rs.EOF = False Then If rs.Fields.Item("LANGUAGE_ID").Value <> 0 Then Session.CodePage = Application("CODEPAGE")(rs.Fields.Item("LANGUAGE_ID").Value - 1) End If %> ">
">
|
|
<% Session.CodePage = intSavedCodePage %> <% ' It also closes any active Recordset objects associated with ' with the connection. If conn.State = adStateOpen Then conn.Close Set rs = Nothing Set cmd = Nothing Set conn = Nothing %>