Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 13th, 2003, 06:46 PM
Authorized User
 
Join Date: Nov 2003
Posts: 85
Thanks: 0
Thanked 0 Times in 0 Posts
Default Update asp-access to mysql

I am having an asp site. Until now, I run it with an access mdb database. It runs in iis5. My site runs smoothly with absolutely no problems.
For reasons everyone knows, I want to make a try to change this database to mysql.
I have installed in my pc, mysql server 3.5.23, which my host provider fully supports.
I also have converted the access to mysql, and i have mysql-front application which helps me use mysql with graphic interface.
I must also say that i have made this site with asp-access to work in asp-mysql for windows. All these problems happen when i test it online in my host, which runs iis5 but the back-end database runs in linux.
I face some problems to this updating, from access to mysql.

I have used succesfully asp script statcountx, which gives excellent statistics. No problems at all, with access, not even with mysql for windows(at my pc). But this not works in my host company.
Now, that I try to upgrade to mysql, it does not run.
There is a file config.asp which holds the data path and some other info.
I have changed this in order to point to the new database.

The problem is that the other specific statistics pages, do not work. There is one page for ip's, one for referes etc. No page works. They display errors.
Examples of errors:

For example: ips.asp gives me this error:
Microsoft OLE DB Provider for ODBC Drivers error '80040e21'

ODBC driver does not support the requested properties.

/wmy/29stats/ips.asp, line 60

Line 60 is this one:rs.Open sSQL,,,adCmdTable


Then i go to see referers. New error:
Microsoft OLE DB Provider for ODBC Drivers error '80040e21'

ODBC driver does not support the requested properties.

/wmy/29stats/reportref.asp, line 53

Line 53 is this one:
rs.Open sSQL, , , adCmdTable



I also include the config.asp code (i have deleted the username and password, and server name from the file, you must be sure it's ok in the original file i have). You can see this:sConnStats = "driver={MySQL};server=;uid=;pwd=;database=" . The original file is ok, because there is an admin file for these statistics that loads correctly.

Because every page is faulty, that makes me believe that it must be something common between them. Maybe config.asp? But the path to mysql is double-checked right.


Here is the code of config.asp :


<%
          'StatCounteX 3.1
     'http://www.2enetworx.com/dev/projects/statcountex.asp



     sConnStats = "driver={MySQL};server=;uid=;pwd=;database="



     'Pre Create the connection and recordset objects
     set conn = Server.CreateObject("ADODB.Connection")
     set rs = Server.CreateObject("ADODB.Recordset")

     'ADO Constants
     '---- CursorTypeEnum Values ----
     Const adOpenForwardOnly = 0
     Const adOpenKeyset = 1
     Const adOpenDynamic = 2
     Const adOpenStatic = 3

     '---- CursorLocationEnum Values ----
     Const adUseServer = 2
     Const adUseClient = 3

     '---- CommandTypeEnum Values ----
     Const adCmdUnknown = &H0008
     Const adCmdText = &H0001
     Const adCmdTable = &H0002
     Const adCmdStoredProc = &H0004
     Const adCmdFile = &H0100
     Const adCmdTableDirect = &H0200

     sub OpenDB(sConn)
          'Opens the given connection and initializes the recordset
          conn.open sConn
          set rs.ActiveConnection = conn
          rs.CursorType = adOpenStatic
     end sub

     sub CloseDB()
          'Closes and destroys the connection and recordset objects
          rs.close
          conn.close
          set rs = nothing
          set conn = nothing
     end sub

     sub w(sText)
          'A Quickie ;)
          response.write sText & vbCrLf
     end sub

     'Load Config from DB

     'Open Connection
     conn.open sConnStats

     'Build SqlString
     strSql = "SELECT C_ImageLoc "
     strSql = strSql & ", C_FilterIP "
     strSql = strSql & ", C_ShowLinks "
     strSql = strSql & ", C_RefThisServer "
     strSql = strSql & ", C_StripPathParameters "
     strSql = strSql & ", C_StripPathProtocol "
     strSql = strSql & ", C_StripRefParameters "
     strSql = strSql & ", C_StripRefProtocol "
     strSql = strSql & ", C_StripRefFile "
     strSql = strSql & "FROM config WHERE ID = 1"

     'Open RecordSet
     set rs = conn.Execute(strSql)

     'Get Variables
     sImageLocation = rs.Fields("C_ImageLoc")
     sFilterIps = rs.Fields("C_FilterIP")
     bShowLinks = rs.Fields("C_ShowLinks")
     bRefThisServer = rs.Fields("C_RefThisServer")
     bStripPathParameters = rs.Fields("C_StripPathParameters")
     bStripPathProtocol = rs.Fields("C_StripPathProtocol")
     bStripRefParameters = rs.Fields("C_StripRefParameters")
     bStripRefProtocol = rs.Fields("C_StripRefProtocol")
     bStripRefFile = rs.Fields("C_StripRefFile")


     'Terminate database connection
     rs.Close
     conn.close

%>


Here is the code of ips.asp which gives error:


<%


' Sub ListIps
'
' Usage:
' lYear - the numerical year (optional)
' lMonth - the numerical month (optional)
' lDay - the numerical day (optional)
' lHour - the numerical hour (optional)
'
Sub ListIps( lYear, lMonth, lDay, lHour )

   sDataSource = ""
   If Len(lHour) > 0 Then
      sDataSource = "GroupIpsByHourAndDate"
   Else
      sDataSource = "GroupIpsByDate"
   End If

   sSQL = "SELECT * From " & sDataSource & " Where 1=1 "

   If Len( lYear ) > 0 Then
      sSQL = sSQL & "and DatePart(""yyyy"",[Date])=" & lYear & " "
   End If

   If Len( lMonth ) > 0 Then
      sSQL = sSQL & "and DatePart( ""m"", [Date])= " & lMonth & " "
   End If

   If Len( lDay ) > 0 Then
      sSQL = sSQL & "and DatePart( ""d"", [Date])= " & lDay & " "
   End If

   If Len( lHour ) > 0 Then
      sSQL = sSQL & "and Hour= " & lHour & " "
   End If

   ' Connect to the database
     OpenDB sconnstats
     rs.Open sSQL,,,adCmdTable

%>
   <table border=0 cellspacing=1 cellpadding=2 bgcolor = "#ffe4b5">
        <tr>
             <td bgcolor="#ffe4b5" width=10>»</td>
             <td class="smallerheader" bgcolor="#ffe4b5">Stats: Visitors on <%=GetDate%></td>
             <td bgcolor="#ffe4b5" width=10></td>
      </tr>
<%
     do while not rs.eof

        sLink = "<a href=""ips.asp?ip=" & rs("IP")

      If Len( lYear ) > 0 Then
         sLink = sLink & "&year=" & lYear
      End If

      If Len( lMonth ) > 0 Then
         sLink = sLink & "&month=" & lMonth
      End If

      If Len( lDay ) > 0 Then
         sLink = sLink & "&day=" & lDay
      End If

      If Len( lHour ) > 0 Then
         sLink = sLink & "&hour=" & lHour
      End If

        sLink = sLink & """>" & rs("IP") & "</a>"
%>
          <tr>
             <td bgcolor="#fffaf0"></td>
             <td bgcolor="#fffaf0"><%=sLink%></td>
             <td bgcolor="#fffaf0"></td>
          </tr>
<%
          rs.movenext
     loop
%>
          <tr>
             <td bgcolor="#fffaf0"></td>
             <td bgcolor="#fffaf0"><%=rs.RecordCount%> visitors</td>
             <td bgcolor="#fffaf0"></td>
          </tr>
     </table>
<%
     conn.close
     'set rs=nothing
     'set conn=nothing
End Sub


'
' Sub ShowClickPath
'
' Usage:
' sIP - The IP to show the click path for.
' lYear - the numerical year (optional)
' lMonth - the numerical month (optional)
' lDay - the numerical day (optional)
' lHour - the numerical hour (optional)
'
Sub ShowClickPath( sIp, lYear, lMonth, lDay, lHour )

   If Len( sIP ) = 0 Then
      Response.Write( "Error: IP Address not provided for displaying a Click Path." )
      Exit Sub
   End If

' sSQL = "SELECT Stats.*, Refs.RefName, Paths.PathName FROM Paths RIGHT JOIN (Refs RIGHT JOIN Stats ON Refs.RefID = Stats.RefID) ON Paths.PathID = Stats.PathID WHERE (((Stats.IP)='"&sIp&"') AND ((Stats.Date)="&sDate&"))"
   sSQL = "SELECT Stats.Date, Stats.Time, Stats.IP, Paths.PathName, Refs.RefName FROM Paths RIGHT JOIN (Refs RIGHT JOIN Stats ON Refs.RefID = Stats.RefID) ON Paths.PathID = Stats.PathID Where Stats.IP='" & sIp & "'"

   If Len( lYear ) > 0 Then
      sSQL = sSQL & " and DatePart(""yyyy"", [Stats].[Date]) = " & lYear
   End If

   If Len( lMonth ) > 0 Then
      sSQL = sSQL & " and DatePart(""m"", [Stats].[Date]) = " & lMonth
   End If

   If Len( lDay ) > 0 Then
      sSQL = sSQL & " and DatePart(""d"", [Stats].[Date]) = " & lDay
   End If

   If Len( lHour ) > 0 Then
      sSQL = sSQL & " and DatePart(""h"", [Stats].[Time]) = " & lHour
   End If

   ' Connect to the database
     OpenDB sConnStats
     rs.Open sSQL,,,adCmdTable

     sFieldName = ""
     If bShowLinks And InStr( rs("RefName"), "http://" ) > 0 Then
        sFieldName = "<a href=""" & rs("RefName") & """>" & rs("RefName") & "</a>"
     Else
          sFieldName = rs("RefName")
     end if
%>
   <table border=0 cellspacing=1 cellpadding=2 bgcolor = "#ffe4b5">
        <tr>
             <td bgcolor="#ffe4b5" width=10>»</td>
             <td colspan=3 class="smallerheader" bgcolor="#ffe4b5">Stats: Click path for <%=sIp%> on <%=rs("Date")%></td>
             <td bgcolor="#ffe4b5" width=10></td>
      </tr>
      <tr>
             <td bgcolor="#fffaf0"></td>
             <td bgcolor="#fffaf0"><%=rs("Date")%></td>
             <td bgcolor="#fffaf0"><%=rs("Time")%></td>
             <td bgcolor="#fffaf0"><%=sFieldName%></td>
             <td bgcolor="#fffaf0"></td>
          </tr>
<%

   ' Calculate totals
     do while not rs.eof

     sFieldName = ""
     If bShowLinks And InStr( rs("PathName"), "http://" ) > 0 Then
        sFieldName = "<a href=""" & rs("PathName") & """>" & rs("PathName") & "</a>"
     Else
          sFieldName = rs("RefName")
     end if
%>
      <tr>
             <td bgcolor="#fffaf0"></td>
             <td bgcolor="#fffaf0"><%=rs("Date")%></td>
             <td bgcolor="#fffaf0"><%=rs("Time")%></td>
             <td bgcolor="#fffaf0"><%=sFieldName%></td>
             <td bgcolor="#fffaf0"></td>
          </tr>
<%
          rs.movenext
     loop
%>
     </table>
<%
     conn.close
     'set rs=nothing
     'set conn=nothing
End Sub

Function GetDate
   If Len(Request.QueryString("Month")) > 0 Then
      GetDate = MonthName(Request.QueryString("Month"))

      If Len(Request.QueryString("Day")) > 0 Then
         GetDate = GetDate & " " & Request.QueryString("Day")
      End If

      GetDate = GetDate & ", "
   End If

   If Len(Request.QueryString("Year")) > 0 Then
      GetDate = GetDate & Request.QueryString("Year")
   End If

   If Len(GetDate) = 0 Then
      GetDate = "All Data"
   End If
End Function

sIp = Request.QueryString( "IP" )
sYear = Request.QueryString( "Year" )
sMonth = Request.QueryString( "Month" )
sDay = Request.QueryString( "Day" )
sHour = Request.QueryString( "Hour" )

%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
     <title>StatCounteX 3.1</title>
     <link rel="stylesheet" type="text/css" href="scx.css">
</head>

<body>
<table border=0 width="100%">
     <td class="title">
          StatCounteX 3.1 Reports
     </td>
     <td class="smallertext" align=right>
          <a href="http://www.2enetworx.com/dev/projects/reportbug.asp?pid=4" target="_blank">Report a Bug</a> |
          <a href="http://www.2enetworx.com/dev/projects/recommend.asp?pid=4" target="_blank">Recommend a feature</a> |
          <a href="http://www.2enetworx.com/dev/projects/question.asp?pid=4" target="_blank">Ask a question</a> |
          <a href="http://www.2enetworx.com/dev/projects/submitsite.asp?pid=4" target="_blank">Submit a site</a>
     </td>
</table>

» <a href="reports.asp">Reports</a> » <a href="reportpathy.asp">Yearly Report</a>
» <a href="reportpathm.asp?year=<%=sYear%>">Monthly Report</a>
» <a href="reportpathd.asp?year=<%=sYear%>&month=<%=sMo nth%>">Daily Report</a>
<%
   If Len( sIp ) > 0 Then
%>
      Â» <a href="ips.asp?year=<%=sYear%>&month=<%=sMonth%>&da y=<%=sDay%>">Visitors Report</a> » Click Path
<%
   Else
%>
      Â» Visitors Report
<%
   End If
%>
<br><br>
<%
   Response.Write( "<b>Displaying Data For " & GetDate & "</b><br><br>" )

   If Len( sIp ) > 0 Then
      ShowClickPath sIp, sYear, sMonth, sDay, sHour
   Else
      ListIps sYear, sMonth, sDay, sHour
   End If
%>

<a href="<%= Request.ServerVariables("HTTP_REFERER") %>">Back to Previous Page</a>


<table border=0 width="100%">
     <tr>
     <td class="smallertext">
     Visit <a href="http://www.2enetworx.com/dev">2eNetWorX</a> for more OpenSource VB and ASP Projects.
     </td>
     <td align="right">
     <a href="http://www.2enetworx.com/dev/projects/statcountex.asp">
     <img src="29images/nine.jpg" width=90 height=30 alt="StatCounteX" border="0">
     </a>
     </td>
     </tr>
</table>

</body>
</html>


Where is the fault? Is it in this file? What make the other file not run correctly?



I hope you help me with these problems, in order to join succesfuly the mysql community, and make my site work fine again.

Thanks in advance
 
Old November 19th, 2003, 05:31 PM
Registered User
 
Join Date: Nov 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Have you installed the ODBC connector for MySQL on the IIS Server?

The ODBC can be found @ http://www.mysql.com/downloads/api-myodbc-3.51.html

I have been running MySQL on a seperate Linux Box without any issues.

The syntax of your code looks correct.

 
Old November 19th, 2003, 05:51 PM
Authorized User
 
Join Date: Nov 2003
Posts: 85
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for your response.

I have already installed this.

The code is also 'ready to go'. It is not written from me.
It belong to stacountx script. It's the best script for traffic analysis in asp language.

But, unfortunatelly, it is too difficult for me to find out what conflicts with mysql database.

So many different messages.

I want to be honest, and i ll say that i had a very tedious conversation about this in another forum.
No luck at all.

So, after very hard work that leads to nothing, i admit that i am ready to give up this.

I am dissapointed. Such a good script (thousand of users download it), work so fine with access, but in mysql only god knows what happens.
I ve searched almost everything.

The only thing that is non done yet, is to take someone this script and look at it. Even if this happen, i really doubt about the results.

The whole thing made me think that even asp is a good language, it's collaboration with mysql is not perfect. But can everyone debug these things?

It would be perfect if i could just change the connection string and everything working. But...

This is it.
Dissapointment.
I really cannot start once again changing things about for a month, only to find that this excellent script is impossible to work with other database than access.

I dont know what to do. I cannot learn now php. I have not ms sql option at my host. No other good asp script for statistics exist. Others want global.asa (i am burned from this), others are just hit counters, and of course must be configured to play with mysql(i tried it).

If there is any good person that wants to take a closer look at this excellent script, i can send it with mail. Or it can be downloaded from their site.


Thanks in advance


 
Old November 30th, 2003, 01:44 PM
Registered User
 
Join Date: Nov 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Jonah Hex
Default

Hi man,
  I saw u post on 2whatever_thesite_was.com about using mySQL the thing about that is there is nothing wrond with the code its in the database there needs to be views instead of quieries from access...

The other problem is that it doesnt provide accurate listings of users eg; opperating systems, browersers, screen sizes.... and pages requested...

The second thing is that the database gets huge!!!!

Ihave been using FSstats and it works great except for script time out and design appearance... both are easy to fix...

Also its all table database so there are no db scrips ... hence very easy to port over to mysql... just add the image to the foooter.asp page if u need more help email me Jonah Hex i might b able 2 help u more

no images sigs suck





Similar Threads
Thread Thread Starter Forum Replies Last Post
access and update the registry through asp Hughesie78 Classic ASP Professional 12 May 16th, 2008 06:19 AM
asp-mysql update error chidomen Classic ASP Databases 1 June 15th, 2005 05:29 PM
unable to update MySQL database with ASP don baroo Classic ASP Databases 7 November 22nd, 2004 01:22 PM
problems: asp files, from access to mysql karib MySQL 0 November 25th, 2003 04:07 PM
Can't update Access database under ASP with ADO bnorg ASP.NET 1.0 and 1.1 Basics 6 September 16th, 2003 02:18 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.