http://www.bynd.net/view-addeddw/clickview.asp In detaild I have added this, please Help me.

In the clickview.asp the link values are not adding having the ID as the Primary Key. When clik on the Link caled by the URL, ir redirects to the redirect.asp ( <a href="redirect.asp?ID=<%=(rsClicks.Fields.Item("URL").Value)%>" target="_blank"> ) and goes to the link that works but it dosent add the value ( objConn.Execute "UPDATE SiteClicks SET ClickCount = ClickCount + 1 WHERE URL='" & SiteURL & "'" ) to the clickcount field in the redirect.asp in the DB. Please help to get this link Views error sorted.

clickview.asp code:

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
Dim MM_connClicks_STRING
MM_connClicks_STRING = ("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("clickcounts.mdb"))
%>
<%
Dim rsClicks
Dim rsClicks_numRows

Set rsClicks = Server.CreateObject("ADODB.Recordset")
rsClicks.ActiveConnection = MM_connClicks_STRING
rsClicks.Source = "SELECT * FROM SiteClicks"
rsClicks.CursorType = 0
rsClicks.CursorLocation = 2
rsClicks.LockType = 1
rsClicks.Open()

rsClicks_numRows = 0
%>
<%
Dim Repeat1__numRows
Dim Repeat1__index

Repeat1__numRows = -1
Repeat1__index = 0
rsClicks_numRows = rsClicks_numRows + Repeat1__numRows
%>
<%
' *** Recordset Stats, Move To Record, and Go To Record: declare stats variables

Dim rsClicks_total
Dim rsClicks_first
Dim rsClicks_last

'set the record count
rsClicks_total = rsClicks.RecordCount

' set the number of rows displayed on this page
If (rsClicks_numRows < 0) Then
rsClicks_numRows = rsClicks_total
Elseif (rsClicks_numRows = 0) Then
rsClicks_numRows = 1
End If

' set the first and last displayed record
rsClicks_first = 1
rsClicks_last = rsClicks_first + rsClicks_numRows - 1

' if we have the correct record count, check the other stats
If (rsClicks_total <> -1) Then
If (rsClicks_first > rsClicks_total) Then
rsClicks_first = rsClicks_total
End If
If (rsClicks_last > rsClicks_total) Then
rsClicks_last = rsClicks_total
End If
If (rsClicks_numRows > rsClicks_total) Then
rsClicks_numRows = rsClicks_total
End If
End If
%>

<%
' *** Recordset Stats: if we don't know the record count, manually count them

If (rsClicks_total = -1) Then

' count the total records by iterating through the recordset
rsClicks_total=0
While (Not rsClicks.EOF)
rsClicks_total = rsClicks_total + 1
rsClicks.MoveNext
Wend

' reset the cursor to the beginning
If (rsClicks.CursorType > 0) Then
rsClicks.MoveFirst
Else
rsClicks.Requery
End If

' set the number of rows displayed on this page
If (rsClicks_numRows < 0 Or rsClicks_numRows > rsClicks_total) Then
rsClicks_numRows = rsClicks_total
End If

'set the first and last displayed record
rsClicks_first = 1
rsClicks_last = rsClicks_first + rsClicks_numRows - 1

If (rsClicks_first > rsClicks_total) Then
rsClicks_first = rsClicks_total
End If
If (rsClicks_last > rsClicks_total) Then
rsClicks_last = rsClicks_total
End If

End If
%>

<html>
<head>
<title>Clickthroughs</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<script language="JavaScript" type="text/JavaScript">
<!--
function mark(face,field_color,text_color){
if (document.documentElement){//if browser is IE5+ or NS6+
face.style.backgroundColor=field_color;
face.style.color=text_color;
}
}
//-->
</script>


<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function PopdbDes(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=425,height=438,left = 330,top = 213');");
}
// End -->
</script>


</head>

<body>
<div align="center"><strong><font size="4" face="Tahoma"> Website Click through    for edit</font></strong></div>
<div align="center"><br>
<table width="65%" border="0">
<tr>
<td> <div align="right"><font size="1" face="Tahoma">
    Showing a total of : <%=(rsClicks_total)%> links </font></div></td>
</tr>
</table>
<table width="65%" border="0" cellpadding="0" cellspacing="0" bgcolor="#000000">
<tr>
<td>
<table width="699" border="0" cellspacing="1">
<tr bgcolor="#3399CC">
<td width="21%"> <font color="#FFFFFF">Name</font></td>
<td width="15%"> <font color="#FFFFFF">Position</font></td>
<td width="11%"> <font color="#FFFFFF">Salary</font></td>
<td width="14%" align="center">
                                                <font face="Times New Roman">URL</font></td>
<td width="8%">
                                                <b>
                        <font face="Arial" size="2" color="#FFFFFF">Age</font></b></td>
<td width="25%"> <div align="center"><font color="#FFFFFF" size="2" face="Tahoma">
<strong>Click through for Description</strong></font></div></td>
</tr>
<%
While ((Repeat1__numRows <> 0) AND (NOT rsClicks.EOF))
%>
<tr bgcolor="#FFFFFF" onMouseOver="mark(this,''#FFFF99'',''#000000'')"
onMouseOut="mark(this,''#FFFFFF'',''#000000'')">
<td width="21%"><font size="1" face="Arial"><%=(rsClicks.Fields.Item("DBName").Value)%></font></td>
<td width="15%"><font size="1" face="Arial"><%=(rsClicks.Fields.Item("DBposition").Value)%></font></td>
<td width="11%"><font size="1" face="Arial"><%=(rsClicks.Fields.Item("DBsalary").Value)%></font></td>
<td width="14%" align="center">


<!-- heres the place where based on ID it calls the URL -->
<a href="redirect.asp?ID=<%=(rsClicks.Fields.Item("URL").Value)%>" target="_blank">
<!-- heres the place where based on ID it calls the URL -->


<font face="Arial" size="1"><%=(rsClicks.Fields.Item("URL").Value)%></font></a></td>
<td width="8%"><font size="1" face="Arial"><%=(rsClicks.Fields.Item("DBage").Value)%></font></td>
<td width="25%">

<p align="center"><font face="Arial" size="1"><span style="font-size: 8.0pt; font-family: Arial">More</span></a>
<b><font color="#FF6600">(</font></b>views:<%=(rsClicks.Fields.Item("ClickCount").Value)%><b><font color="#FF6600">)</font></b></span></td>
</tr>
<%
Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
rsClicks.MoveNext()
Wend
%>
</table></td>
</tr>
</table>

<br>
<br>
</div>
<table border="1" width="100%" cellspacing="5\" id="table1" cellpadding="5" bgcolor="#000000">
    <tr>
        <td width="331">
        <img border="0" src="images/001.jpg" width="331" height="334"></td>
        <td>
        <p align="center">
        <img border="0" src="images/002.jpg" width="499" height="512"></td>
    </tr>
    <tr>
        <td colspan="2">
        <br>
        <img border="0" src="images/003.jpg" width="924" height="221"></td>
    </tr>
</table>
</body>
</html>
<%
rsClicks.Close()
Set rsClicks = Nothing
%>

redirect.asp code:

<%
'SiteURL = Request.QueryString("URL")
 SiteURL = Request.QueryString("ID")

If Len(SiteURL) > 0 Then
Set objConn = CreateObject("ADODB.Connection")
objConn.Open "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("/view-addeddw/clickcounts.mdb") & ";Persist Security Info=False"

' If the URL is already in the database an error will be thrown and we perform an UPDATE Instead of a INSERT.

on error resume next
'objConn.Execute "INSERT INTO SiteClicks(URL,ClickCount) VALUES('" & SiteURL & "',1)"
If Err.Number <> 0 Then
 objConn.Execute "UPDATE SiteClicks SET ClickCount = ClickCount + 1 WHERE URL='" & SiteURL & "'"
'objConn.Execute "UPDATE SiteClicks SET ClickCount = ClickCount + 1 WHERE URL='" & SiteURL & "'"

 'rs.Execute("UPDATE salinfo SET ClickCount = ClickCount + 1 WHERE ID=" & rs("ID"))

End If
objConn.Close
Set objConn= Nothing
Response.redirect SiteURL
End If

%>

http://www.bynd.net/view-addeddw/clickview.asp In detaild I have added this, please Help me.

Thank you.

I.A

Hi,
in redirect.asp:
SiteURL = Request.QueryString("ID")
objConn.Execute "UPDATE SiteClicks SET ClickCount = ClickCount + 1 WHERE URL='" & SiteURL & "'"

You have to change the SQL to :

objConn.Execute "UPDATE SiteClicks SET ClickCount = ClickCount + 1 WHERE ID=" & SiteURL

You are getting the ID, but you are trying to compare the fields with the URLs. As the ID is not equal to any URL, the update does not work. ;)

Hi,

Thank you so much for the reply, I tried all ways Sir and I do not know whats wrong with it, I have Added a '"Download" Link and the entire project can also be downloaded, Its all working and loading the page based on the ID too and redirecting, only thing is Its giving a another Row for the Link Count.

Can U please fix it Sir and Help me. I am confused.

http://www.bynd.net/view-addeddw/clickview.asp Please click on download and after a clicking the more please Refresh the Link value is added on another row insted on the same.

Plese Help me to sort this Link count asp db code.

Thank you.

Hi,
in redirect.asp:
SiteURL = Request.QueryString("ID")
objConn.Execute "UPDATE SiteClicks SET ClickCount = ClickCount + 1 WHERE URL='" & SiteURL & "'"

You have to change the SQL to :

objConn.Execute "UPDATE SiteClicks SET ClickCount = ClickCount + 1 WHERE ID=" & SiteURL

You are getting the ID, but you are trying to compare the fields with the URLs. As the ID is not equal to any URL, the update does not work. ;)

Sorted Got it work by another mate thank you.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.