From: BD on
I'm trying to build a hit counter that does what I want using an Access
database named counters.mdb which contains 2 tables. The only one involved
here is page_count. Here is the code for the aspx test page.
===============================
<%@ Page Language="VB" Debug="true" runat="server"%>
<%@ import Namespace="System.Data.OLEDB" %>

<script runat="server" language="vb">
Function pCount()
Const adOpenKeyset = 1
Const adLockPessimistic = 2
Const adCmdText = &H0001
Dim hCount As Integer
Dim sPage = Request.FilePath.Remove(0,Request.FilePath.LastIndexOf("/")
+1)
Dim sCmd = "SELECT * FROM page_count WHERE pagename='" & sPage & "';"
Dim dSource As String = Server.MapPath("counters.mdb"), sTest As String =
""
Dim rsCounter = Server.CreateObject("ADODB.Recordset")
rsCounter.Open(sCmd, "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
dSource & ";", _
adOpenKeyset, adLockPessimistic, adCmdText)
If rsCounter.EOF Then
sTest = "EOF has been reached."
'rsCounter.AddNew() 'uncommenting this line will throw an error
'rsCounter.Fields("pagename").Value = sPage
End If
rsCounter.Close()
rsCounter = nothing
Dim rTxt = "<p>The database path is: " & dSource & "</p><p>" & sTest &
"</p><p>The page is: " & sPage & "</p>"
Return rTxt
End Function
</script>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Hit Counter Test</title>
</head>
<body>
<%Response.write(pCount())%>
</body>
</html>
=========================================
This produces the correct output, however if I uncomment the line
rsCounter.AddNew()
it starts throwing the following error
System.Runtime.InteropServices.COMException: Cannot update. Database or
object is read-only.

Could someone please tell me what is wrong? I've been at this since
yesterday.
If I have posted this in the wrong group then please direct me to the right
one
Thanks


From: Bob Barrows [MVP] on
BD wrote:
> I'm trying to build a hit counter that does what I want using an
> Access database named counters.mdb which contains 2 tables. The only
> one involved here is page_count. Here is the code for the aspx test
> page.

There was no way for you to know it (except maybe by browsing through
some of the previous questions before posting yours - always a
recommended practice), but this is a classic asp newsgroup. ASP.Net is
a different technology from classic ASP. While you may be lucky enough
to find a dotnet-savvy person here who can answer your question, you
can eliminate the luck factor by posting your question to a newsgroup
where the dotnet-savvy people hang out. I suggest
microsoft.public.dotnet.framework.aspnet.
There are also forums at www.asp.net where you can find a lot of people
to help you.

HTH,
Bob Barrows

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.


From: BD on
Thanks Bob.
As a former MVP myself I should have known to look for more news groups.
"Bob Barrows [MVP]" <reb01501(a)NOyahoo.SPAMcom> wrote in message
news:OB4S20EsIHA.5000(a)TK2MSFTNGP04.phx.gbl...
> There was no way for you to know it (except maybe by browsing through
> some of the previous questions before posting yours - always a
> recommended practice), but this is a classic asp newsgroup. ASP.Net is
> a different technology from classic ASP. While you may be lucky enough
> to find a dotnet-savvy person here who can answer your question, you
> can eliminate the luck factor by posting your question to a newsgroup
> where the dotnet-savvy people hang out. I suggest
> microsoft.public.dotnet.framework.aspnet.
> There are also forums at www.asp.net where you can find a lot of people
> to help you.
>
> HTH,
> Bob Barrows
>
> --
> Microsoft MVP -- ASP/ASP.NET
> Please reply to the newsgroup. The email account listed in my From
> header is my spam trap, so I don't check it very often. You will get a
> quicker response by posting to the newsgroup.
>
>


From: Bob Barrows [MVP] on
I meant to post the solution - hopefully you are still reading:
BD wrote:
> Dim rsCounter = Server.CreateObject("ADODB.Recordset")

Err ... you really should be using ADO.Net rather than ADO.
> System.Runtime.InteropServices.COMException: Cannot update. Database
> or object is read-only.
This is always file-system-permissions-related. All users of an mdb file
require Modify permissions for the _folder_ containing the database.
This is to allow users to create, modify and delete the jet locking file
(.ldb) that controls multi-user access to the mdb file
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.


From: BD on
I'm still reading, thanks Bob.
I am still new to ASP and ASP.NET so I will need some hand holding here. I
don't understand what you have stated in your reply. How would I go about
doing this? Bear in mind that I am testing on IIS 6 and eventually the file
has to be uploaded to a Server 2003 system. All I need is a simple page hit
counter (database). The remaining table in my database is for tracking file
downloads so I'm thinking that If I can get the page hit to work, then the
downloads counter will be easier.
Do you have a web site on the mvps (Karls) server? Yes or no will probably
suffice. I should be able to find it from there.


"Bob Barrows [MVP]" <reb01501(a)NOyahoo.SPAMcom> wrote in message
news:%23vR469EsIHA.2064(a)TK2MSFTNGP05.phx.gbl...
>I meant to post the solution - hopefully you are still reading:
> BD wrote:
>> Dim rsCounter = Server.CreateObject("ADODB.Recordset")
>
> Err ... you really should be using ADO.Net rather than ADO.
>> System.Runtime.InteropServices.COMException: Cannot update. Database
>> or object is read-only.
> This is always file-system-permissions-related. All users of an mdb file
> require Modify permissions for the _folder_ containing the database.
> This is to allow users to create, modify and delete the jet locking file
> (.ldb) that controls multi-user access to the mdb file
> --
> Microsoft MVP -- ASP/ASP.NET
> Please reply to the newsgroup. The email account listed in my From
> header is my spam trap, so I don't check it very often. You will get a
> quicker response by posting to the newsgroup.
>
>