Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How they got to your page???
Message
 
 
To
24/02/2003 14:46:49
Tom Gahagan
Alliance Computer Solutions
Thomaston, Georgia, United States
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
00756846
Message ID:
00757155
Views:
13
Hi Tom,

I'm trying something simple, but it doesn't work for me. Could you please try it (you can modify select statement and connection to use your data). I took code directly from tek-tips, but I can not open recordset using my SQL statement. I don't know, what's wrong, and it's frustrating...
<%@language=vbscript%>
<%option explicit

Const adOpenForwardOnly = 0
Const adLockReadOnly = 1
Const adCmdTableDirect = &H0200
Const adUseClient = 3
dim strSQL, objRS, I, icount, records, strConn
Dim objConnection

'    objConnection = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source="
'    objConnection = objConnection & Server.MapPath("\datbase.mdb")
objConnection = "Driver={SQL SERVER};SERVER=NADYA;DATABASE=CTCredit;UID=;PWD=;"

'The Search page can have an option how many records to display per page
records = request.querystring("records") 
'records = 10 ' Hardcode for now

'set objConnection = server.CreateObject("ADODB.Connection")

set objRS = server.CreateObject("ADODB.Recordset")
objRS.PageSize = 6
objRS.CacheSize = 300
objRS.CursorLocation = adUseClient

dim SearchString 
SearchString = "" 
strSQL = ""
icount = ""

'take all the form details and store them in the variables
'searchstring = Request.querystring("txtsearch")

strSQL = "select CredID, CreditCat, ccode, town, Address from " & _ 
         "CreditInfo where town in ('MLFD','COLC','OLYM') order by CreditCat, Address"


'strSQL = "SELECT * FROM table WHERE fieldname='" & searchstring & "'"

objRS.Open strSQL, objConnection, adOpenForwardOnly, adLockReadOnly, adCmdTableDirect

'objConnection.Open strConn
'set objRS = objConnection.Execute(strSQL)

%>

<html>
<head>
<title>Results</title>
</head>
<body bgcolor="#ffffff">
<table width="600" border="0" cellspacing="0" cellpadding="0" align="center">
  <tr> 
    <td width="58" height="37"></td>
    <td bgcolor="#f7ca73" height="37" width="157</td>
    <td bgcolor="#f7ca73" height="37">
      <div align="right">HEADER</div>
    </td>
    <td width="39" height="37"></td>
  </tr>
  <tr> 
    <td width="58" valign="top"></td>
    <td valign="top" colspan="2"><%if objRS.EOF and objRS.BOF then
    response.write("Your search has returned no results, please re search the database using a different criteria.")
  else
'***************************************
'start the loop in the recordset here
'***************************************
            If Len(request.querystring("records")) = 0 then
                objRS.AbsolutePage = 1
            Else
            If CInt(request.querystring("records")) <= objRS.PageCount then
                objRS.AbsolutePage = request.querystring("records")
            Else
                objRS.AbsolutePage = 1
            End if
            End if
                            
            Dim abspage, pagecnt, IntLoop
            
            abspage = objRS.AbsolutePage
            pagecnt = objRS.PageCount
            IntLoop = 0

            'response.write("<TABLE WIDTH='100%' cellpadding=0 cellspacing=0 border=0>")
    %>
    <table width="100%" border=1>
    <tr bgcolor=#ffcc66><td><div class="tblelement"><b>Click to<br>Select Record</b></div></td>
    <td><div class="tblelement"><b>Category</b></div></td>
    <td><div class="tblelement"><b>Town</b></div></td>
    <td><div class="tblelement"><b>Street Address</b></div></td></tr>
    </tr>
    <%
            Dim Fields
            For I = 1 to objRS.PageSize
                IntLoop = IntLoop + 1
                If Not objRS.EOF Then
                    'write the table data onto the page with the recordset details.
'response.write "<TR><TD>" & objRS("fieldname") & "</TD></TR>"

       if intLoop mod 2 = 1 then 'Odd records %>
          <tr bgcolor="white">
       <% Else %>
         <tr bgcolor="#ffffcc"> 
                  
       <% End if %>
       
    <td><div class="star"><input type="checkbox" name="selection" value="<%= oRs.Fields ("CredID").Value %>" checked onClick="parent.data.clientp.toggle(0)">
          </div></td>    
   
    <TD><div class="tblelement"><% = oRs.Fields ("CreditCat").Value %> </div></TD>
    
    <TD><div class="tblelement"> <% = oRs.Fields ("town").Value %> </div></TD>
    <TD><div class="tblelement"> <% = oRs.Fields ("ADDRESS").Value %> </div></TD>    
</TR>
    <%                 objRS.movenext
                end if
            Next
                    
                

'***************************************
'end the loop in the recordset here
'***************************************
    response.write("</table>")
end if 

objRS.close
set objRS = nothing

%> 
    </td>
    <td width="39"></td>
  </tr>
<tr> 
    <td width="58" height="2"></td>
    <td height="2" class="footer" bgcolor="#ffffff" colspan="2"> 
      <div align="right">
<%
'********************************************************
'put the navigation links on the bottom of the page here
'********************************************************

   Response.Write "<div align='right'>" & vbcrlf
   Response.Write "<a href='"
   Response.Write "search.asp"
   Response.Write "?records=1&txtsearch="& request.querystring("slideshow") & "'>First Page</a>"
   Response.Write " | "

   If abspage = 1 Then
      Response.Write "<span style='color:silver;'>Previous Page</span>"
   Else
      Response.Write "<a href='" & Request.ServerVariables("SCRIPT_NAME")
      Response.Write "?records=" & abspage - 1 & "&txtsearch=" & request.querystring("txtsearch")& "'>Previous Page</a>"
   End If

   Response.Write " | "
   If abspage < pagecnt Then
      Response.Write "<a href='" & Request.ServerVariables("SCRIPT_NAME")
      Response.Write "?txtsearch=" & request.querystring("txtsearch") & "&records=" & abspage + 1 & "'>Next Page</a>"
   Else
      Response.Write "<span style='color:silver;'>Next Page</span>"
   End If

   Response.Write " | "
   Response.Write "<a href='" & Request.ServerVariables("SCRIPT_NAME")
      Response.Write "?txtsearch=" & request.querystring("txtsearch") & "&records=" & pagecnt & "'>Last Page</a>"
   Response.Write "</div>" & vbcrlf

   


'********************************************************
'end the navigation links on the bottom of the page here
'********************************************************
%></div>
    </td>
  </tr>
  <tr> 
    <td width="58" height="2"></td>
    <td height="2" bgcolor="#f7ca73" colspan="2"> 
          </td>
  </tr>
  <tr> 
    <td width="58" height="2"></td>
    <td height="2" bgcolor="#f7ca73" colspan="2"> 
      
    </td>
  </tr>
</table>
</body>
</HTML>


>I'll check it out.. .thanks.
>Did some reading based on his reply... you may want to check out my reply to him. Turns out this method is not very reliable.
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform