Click to See Complete Forum and Search --> : What is wrong in this code?


tasneem
05-06-2005, 05:01 PM
Hi
This is the code to retrieve records from access db to an asp page:


<!--#include file="dbconn.asp" --> 'my connection string.
<%
Dim rsmidtowncats
Dim rsmidtowncats_numRows

Set rsmidtowncats = Server.CreateObject("ADODB.Recordset")
Set midtowncnn = Server.CreateObject("ADODB.Connection")
midtowncnn.open dsnmidtown

strsql = "SELECT * FROM tblMasterCategoryNames"

rsmidtowncats.open strsql,midtowncnn,0,2,1
'rsmidtowncats.Open()

rsmidtowncats_numRows = 0
%>


Then I put this records in the table in this way:


<table border="0" id="tblmaincats">
<tr>
<td>MasterCategoryID</td>
<td>MasterCategoryName</td>
</tr>
<% While ((Repeat1__numRows <> 0) AND (NOT rsmidtowncats.EOF)) %>
<tr>
<td><%=(rsmidtown.Fields.Item("MasterCategoryID").Value) %></td>
<td><%=(rsmidtown.Fields.Item("MasterCategoryName").Value) %></td>
</tr>
<%
Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
rsmidtowncats.MoveNext()
Wend
%>
</table>


Why is the returning an empty recordset?
The records here are only 4, and this is working in query in access db.
Can anyone help?

thanks

wmif
05-06-2005, 05:28 PM
are you using those repeat1 variables for anything thats not displayed. that might be tripping your while function.

phpnovice
05-07-2005, 10:41 AM
In other words... You didn't show anything that initializes the Repeat1__numRows variable with a value. You might also try adding the following at the top of your page to catch any undeclared variables:

<% @Language=VBScript %>
<% Option Explicit %>

tasneem
05-07-2005, 02:55 PM
Hi
I got it working, removed the repeat variables. I also put a check to see whether it is connecting to the db, and doing the query from the browser. Anyway, I got the correct fields and values now.

I have one question though:
Whenever I change an asp or for that matter a php page, and refresh it in browser, it does not get refreshed?? I checked the cache and did a google on this, and all it says is about cache. I am talking about my development server here, so is there any change I have to make in IIS 6.0 or IE ?? I have to save the current asp/php page under a different name (I just add a number to it like asp.asp, asp1.asp and so on) and then I can see the changes. So I am pretty sure it is something to do with either IE settings or IIS settings, but I just don't know what. Does anybody have any idea about this?

thanks

wmif
05-10-2005, 03:14 PM
tell your browser to check for new updates every visit.

also, you can put this at the top of your pages:
Response.Expires=0
Response.AddHeader "pragma","no-cache"