RecordCount not working???

Results 1 to 2 of 2

Thread: RecordCount not working???

  1. #1
    Join Date
    Dec 1969

    Default RecordCount not working???

    I am working with a banner management code.<BR>This code from below: rndMax = CInt(brec3.RecordCount)<BR>is returning negative numbers with about 100 records in the table. If I try MaxRecords it gives me a 0. Do I have something written wrong. Basically I can asking for the Max Number of records so I can create a random number to display the different banner when ever the page is refreshed.<BR><BR>The only way it work is if I replace <BR>rndMax = CInt(brec3.RecordCount) with the actuall number of records rndMax = 125<BR><BR>Actual Code-----------------------------------<BR>&#060;% <BR><BR> dim bannerconnection, brec1, brec2, brec3, brec4<BR> set bannerconnection = server.createobject("adodb.connection")<BR> myDSN<BR> size = 1<BR> todaydt = Date()<BR> <BR> S2 = "Select * from banner where bsize = " & size & " and nod &#060; maxd and status = 1 ;"<BR> Set brec3 = Server.CreateObject( "ADODB.Recordset" )<BR> brec3.CursorType = adOpenStatic<BR> brec3.Open S2, bannerconnection<BR>&#039;--------------<BR>rndMax = CInt(brec3.RecordCount)<BR><BR>response.write ""&rndMax <BR>&#039;here is where I am testing to see what is being displayed for record count<BR><BR>rndMax = Eval(rndMax) - 1<BR><BR>Randomize()<BR>x = Rnd()<BR>rndNumber = Int(x * rndMax)<BR><BR>if rndNumber&#060; 0 then<BR> rndNumber = 0<BR>end if <BR>brec3.Move rndNumber<BR><BR>&#039;----------------<BR> bid = brec3("id")<BR> S2 = "Select nod from banner where id=" & bid <BR><BR> set brec4 = bannerconnection.execute(S2)<BR> nod = brec4("nod")<BR> newnod = Eval(nod) + 1<BR> S2 = "UPDATE banner set nod=" & newnod & " where id=" & bid & ";"<BR><BR> set brec4 = bannerconnection.execute(S2)<BR> <BR>referepage = Request.ServerVariables("Script_name")<BR>refereip = Request.ServerVariables("REMOTE_ADDR")<BR><BR> S2 = "insert into bannerdisplay (bnrid, dt, ipaddr, referepage) values (" & bid & ",&#039;" & date() & "&#039;,&#039;" & refereip & "&#039;,&#039;" & referepage & "&#039;)"<BR><BR> set brec4 = bannerconnection.execute(S2)<BR><BR>%&#062;

  2. #2
    Join Date
    Dec 1969

    Default Did you #include

    Did you check the ASPFAQs, in the category "Databases, Errors"?<BR><BR>It would seem you did, since you are setting the cursor to static, but if adOpenStatic isn&#039;t *defined* then you are just setting the cursor to zero, which does nothing useful.<BR><BR>It&#039;s also possible that the DB you are using doesn&#039;t support the static cursor, no matter what. But you don&#039;t say what DB you are using. I can see that it is not Access, but beyond that I dunno.<BR><BR><BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts