Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2005
    Posts
    37

    Unanswered: RecordCount Problem

    Hello,

    Sorry to trouble u guy again, i tried using a few method from the forum and fail. So anyone can help me out with this, i wanted to count the total number of record in the on of the table Namecard, so tried this code but fail, anyone can help me out?

    <%
    Dim rsCount
    Dim MyConn
    Set MyConn = Server.CreateObject("ADODB.Connection")
    MdbFilePath = Server.MapPath("Admin.mdb")
    MyConn.Open "UID=User;PWD=111111;Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & MdbFilePath & ";"
    Set RS = Server.CreateObject("ADODB.Recordset")
    Set rsCount = Server.CreateObject("ADODB.Recordset")
    %>


    Thanks

    <tr>
    <td height="18" colspan="10" bgcolor="#CECFCE"><span class="style15">You have
    <%
    Set rsCount = MyConn.Open
    rsCount.MoveLast : rsCount.MoveFirst
    intCount = rsCount.RecordCount
    Response.Write(intCount)
    %>
    of contacts</span></td>

  2. #2
    Join Date
    Feb 2005
    Location
    The Hague, Netherlands
    Posts
    95
    I cant help you with the solution, but I think you should post more info about how it fails. Error messages? Debugging? What exactly happens? etc.

  3. #3
    Join Date
    Jan 2005
    Posts
    37
    The error message is

    ADODB.Connection error '800a0e79'

    Operation is not allowed when the object is open.

    /i-Metz/iMetzContacts.asp, line 430

  4. #4
    Join Date
    Feb 2005
    Location
    The Hague, Netherlands
    Posts
    95
    Quote Originally Posted by shoei82
    The error message is

    ADODB.Connection error '800a0e79'

    Operation is not allowed when the object is open.

    /i-Metz/iMetzContacts.asp, line 430
    Hm since it says its 'not allowed when the object is open' and I dont see you closing the db-connection in your code, that might be the problem. Try putting 'set rscount = nothing' at the end of your first block of code (and for that matter, at the end of your second; you should always close a connection when you're finished with it).
    Oh and set myconn = nothing too.

    Again, I'm not an expert in this but I read of this (maybe syntaxis is wrong in my suggestion, google it, i'd say)

Posting Permissions

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