1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Database MySQL query with ASP

Discussion in 'C#' started by Mike1961, Apr 9, 2008.

  1. #1
    Well the situation is this, I have two tables:

    1) tbl_registry where rows with code = 123 are 35 ;
    1) tbl_Registered where rows with code = 123 are 43

    In tbl_Registered I have it 7 rows more respect tbl_registry can you tell my why I have this situation:



    In tbl_Registered the rows is perfectly equal EXCEPT for the field HOURS and the field ACTIVITIES:

    That is JOHN today 2008-04-08 has divided the total of 5 hours in two pieces of activity (2 -XYZ- and the other from 3-ABC-), while JIM has concentrated the total 5 hours only activity ABC.

    I would like to query data extracts are the same:

    Tot tbl_Registry = 35 ===> is right
    Tot tbl_Registered = 35 ===> is right

    Tot tbl_Registry = 35 ===> is right
    Tot tbl_Registered = 43 ===> is wrong

    My queries:

    <%
    sql_count = " SELECT "
    sql_count = sql_count & " COUNT(CODE) "
    sql_count = sql_count & " FROM "
    sql_count = sql_count & " tbl_registry "
    sql_count = sql_count & " WHERE "
    sql_count = sql_count & " CODE LIKE '123%' "
    sql_count = sql_count & " AND "
    sql_count = sql_count & " Q = 'AAA' "
       
    Set objRS = Server.CreateObject("ADODB.Recordset")
    objRS.Open sql_count, cn
    
       response.write objRS(0) & "<br>"
    
    objRS.Close
    Set objRS = Nothing
    
    sql = " SELECT"
    sql = sql & " DATE,"
    sql = sql & " CODE,"
    sql = sql & " Q,"
    sql = sql & " COUNT(CODE) AS tot"
    sql = sql & " FROM " 
    sql = sql & " tbl_Registered "
    sql = sql & " WHERE "
    sql = sql & " CODE LIKE '123%'"
    sql = sql & " AND DATE = '2008-04-08'"
    sql = sql & " AND Q = 'AAA'"
    sql = sql & " GROUP BY "
    sql = sql & " DATE "
    
    Set RS = Server.CreateObject("ADODB.Recordset")
    RS.Open sql, cn
    
    response.write RS("tot") & "<br>"
    
    RS.Close
    Set RS = Nothing
    
    cn.Close
    Set cn = Nothing 
    
    %>
    
    Code (markup):
    I attach sql tables, excel files and asp page; PSW the ZIP file is forum.

    Thanks for your help.
     

    Attached Files:

    Mike1961, Apr 9, 2008 IP
  2. itcn

    itcn Well-Known Member

    Messages:
    795
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    118
    #2
    THat's a little much; can you break it down into exactly what line(s) you are having problems with?
     
    itcn, Apr 22, 2008 IP
  3. clinton

    clinton Well-Known Member

    Messages:
    2,166
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    110
    #3
    I don't think ASP supports MySql, as far as I know but I may be wrong.
     
    clinton, Apr 22, 2008 IP
  4. itcn

    itcn Well-Known Member

    Messages:
    795
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    118
    #4
    It does, you just have to install the MySQL Driver and use the connection string:
    Driver={MySQL ODBC 3.51 Driver}; Server=localhost; Database=yourDB;uid=yourUser; pwd=yourPass;
     
    itcn, Apr 23, 2008 IP