www.webdeveloper.com
Results 1 to 5 of 5

Thread: sql - function count

  1. #1
    Join Date
    Nov 2005
    Posts
    187

    sql - function count

    Hi, I'm having a problem with mysql (again). my problem is with the count function. I'm writing the following code :
    k=objConn.Execute( "SELECT COUNT(zipcode) FROM addition ")

    A.but when I try to use K, it says that I don't have a default value for it, anyone knows why, and what should I do?

    B. Somone knows a good website for SQL, where I can learn the right syntax for it. I'm using w3shools, but almost anything I type through me an error.

    Thanks for the time, Oz.

  2. #2
    Join Date
    Dec 2003
    Location
    England, UK
    Posts
    432
    you sql looks fine to me. its the vbscript that's giving you the error.

    here's a couple of examples of how to connect to a database and retrieve something. i almost always go with the second one because you can specify cursor and lock types, and you don't have to bother creating a connection object explicitly. the first one is useful if you want to run more than one statement in a single transaction.

    (note that this will only show the first record and first field of what you select)


    Code:
    <%
    
    connstr = "put your connection string here"
    sql = "put your select sql statement here"
    
    
    'using connection and recordset objects
    
    set conn = createobject("adodb.connection")
    
    conn.open connstr
    
    set rs = conn.execute(sql)
    
    if not rs.eof then
    
    	response.write rs(0)
    
    end if
    
    rs.close
    conn.close
    
    set conn = nothing
    set rs = nothing
    
    
    '
    ' or using recordset only
    '
    
    set rs = createobject("adodb.recordset")
    
    rs.open sql,connstr
    
    if not rs.eof then
    
    	response.write rs(0)
    
    end if
    
    rs.close
    set rs = nothing
    
    %>

  3. #3
    Join Date
    Nov 2005
    Posts
    187

    Still doesn't work

    Thanks for the help, but I tried and it still doesn't work.

    Maybe I'm not using the function right. Anyone has an idea?

  4. #4
    Join Date
    Dec 2003
    Location
    England, UK
    Posts
    432
    as long as there is a column called zipcode in a table called addition your query is ok

  5. #5
    Join Date
    Nov 2005
    Posts
    187

    So what should I do?

    Do you have any idea what can be wrong, because it simply doesn't want to work.
    That's what it says when I run it:

    Microsoft OLE DB Provider for ODBC Drivers (0x80040E31)
    [MySQL][ODBC 3.51 Driver][mysqld-5.0.16-nt]FUNCTION contractors.COUNT does not exist
    /managment/debug.asp, line 14
    Last edited by ozpo1; 12-10-2005 at 05:37 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles