please dont rip this site

.Asp Examples

The examples in this section show how to build queries with query-object properties and methods.

Example 1

This example uses VBScript code to create a query object, set query parameters and execute the query, producing a record set for iterating over results.


<% REM Create the query and record set objects. %>
<% set Query = Server.CreateObject("IXSSO.Query") %>
<% if IsObject(Query) = FALSE then %>
   The IXS SSO has not been installed correctly. Please contact the Webmaster for this site.
<% else %>
   <% iRequest = Request.ServerVariables("QUERY_STRING") %>
   <% Query.SetQueryFromURL(iRequest)
      set RS=Query.CreateRecordSet("sequential")
   %>
<% end if %>

Example 2

Next, this example gives VBScript code to iterate over the query results using ADO, and output the query results.


<TABLE CELLPADDING=5 BORDER=0>

<!-- BEGIN column header -->

<TR>
   <TD ALIGN=CENTER>
   <FONT STYLE="ARIAL NARROW" SIZE=1>Record</FONT>
   </TD>
   <TD ALIGN=CENTER >
   <FONT STYLE="ARIAL NARROW" SIZE=1>File name</FONT>
   </TD>
   <TD ALIGN=CENTER WIDTH=160 >
   <FONT STYLE="ARIAL NARROW"  SIZE=1>Path</FONT>
   </TD>
   <TD ALIGN=CENTER >
   <FONT STYLE="ARIAL NARROW" SIZE=1>Size</FONT>
   </TD>
   <TD ALIGN=CENTER >
   <FONT STYLE="ARIAL NARROW" SIZE=1>Write</FONT>
   </TD>
</TR>

<!-- BEGIN first row of query results table -->
<%NextRecordNumber = 1%>
<% Do While Not RS.EOF%>
  <TR>
   <TD ALIGN=CENTER>
   <FONT STYLE="ARIAL NARROW" SIZE=1><%=NextRecordNumber %>.</FONT></TD>
   <TD ALIGN=CENTER>
   <FONT STYLE="ARIAL NARROW" SIZE=1><%=RS("FileName")%></FONT></TD>
   <TD ALIGN=CENTER>
   <FONT STYLE="ARIAL NARROW" SIZE=1><A HREF="http::<%=RS("vpath")%>"><%=RS("vpath")%></A></FONT></TD>
   <TD ALIGN=CENTER>
   <FONT STYLE="ARIAL NARROW" SIZE=1><%=RS("Size")%></FONT></TD>
   <TD ALIGN=CENTER>
   <FONT STYLE="ARIAL NARROW" SIZE=1><%=RS("Write")%></FONT></TD>
  </TR>
<%
   RS.MoveNext
   NextRecordNumber = NextRecordNumber+1
  Loop
%>

Example 3

This example shows how the query and record set can be cached in session variables for reuse on another page:

<%
   if IsObject(Session("Query")) And IsObject(Session("record set"))
   then
      set Q = Session("Query")
      set RS = Session("record set")
      if RS.RecordCount < > -1 and NextPageNumber < > -1 then
         RS.AbsolutePage = NextPageNumber
         NextRecordNumber = RS.AbsolutePosition
      end if
      ActiveQuery = TRUE
   else
      <!-- Create new query (code omitted for brevity) -->
   end if
%>

<!-- Later on the page -->
<%
   ' If either of the previous or back buttons were displayed, save
   ' the query and the record set in session variables.
   if SaveQuery then
      set Session("Query") = Q
      set Session("record set") = RS
   else
      RS.close
      Set RS = Nothing
      Set Q = Nothing
      set Session("Query") = Nothing
      set Session("record set") = Nothing
   end if

%>

Example 4

The next example shows how the QUERY_STRING or form variables can be parsed from VBScript without requiring the SetQueryFromURL method.


<%
   NewQuery = FALSE
   UseSavedQuery = FALSE
   SearchString = ""
   if Request.ServerVariables("REQUEST_METHOD") = "POST" then
         NewQuery = TRUE
      SearchString = Request.Form("SearchString")
      SortBy = Request.Form("SortBy")
      Colset = Request.Form("ColChoice")
      Catalog = Request.Form("Catalog")
      if Request.Form("Action") = "New Query" then
      end if
   end if
   if Request.ServerVariables("REQUEST_METHOD") = "GET" then
      SearchString = Request.QueryString("qu")
      SortBy = Request.QueryString("so")
      Colset = Request.QueryString("co")
      Catalog = Request.QueryString("ct")
      if Request.QueryString("pg") <> "" then
         NextPageNumber = Request.QueryString("pg")
         NewQuery = FALSE
         UseSavedQuery = TRUE
      else
         NewQuery = SearchString <> ""
      end if
   end if
 %>

© 1997 by Microsoft Corporation. All rights reserved.


file: /Techref/language/asp/ix/ixaspexp.htm, 8KB, , updated: 1997/9/29 02:23, local time: 2024/11/27 03:29,
TOP NEW HELP FIND: 
3.145.112.23:LOG IN

 ©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions?
Please DO link to this page! Digg it! / MAKE!

<A HREF="http://massmind.org/techref/language/asp/ix/ixaspexp.htm"> Microsoft Index Server: .Asp Examples</A>

After you find an appropriate page, you are invited to your to this massmind site! (posts will be visible only to you before review) Just type a nice message (short messages are blocked as spam) in the box and press the Post button. (HTML welcomed, but not the <A tag: Instead, use the link box to link to another page. A tutorial is available Members can login to post directly, become page editors, and be credited for their posts.


Link? Put it here: 
if you want a response, please enter your email address: 
Attn spammers: All posts are reviewed before being made visible to anyone other than the poster.
Did you find what you needed?

 

Welcome to massmind.org!

 

Welcome to massmind.org!

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  .