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

Re: New problem by Bob

Bob
Wed May 07 09:18:22 CDT 2008

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.



Re: New problem by BD

BD
Wed May 07 09:26:16 CDT 2008

Thanks Bob.
As a former MVP myself I should have known to look for more news groups.
"Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> wrote in message
news:OB4S20EsIHA.5000@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.
>
>



Re: New problem by Bob

Bob
Wed May 07 09:34:36 CDT 2008

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.



Re: New problem by BD

BD
Wed May 07 10:11:11 CDT 2008

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@NOyahoo.SPAMcom> wrote in message
news:%23vR469EsIHA.2064@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.
>
>



Re: New problem by Bob

Bob
Wed May 07 10:27:43 CDT 2008

It's file-system permissions. Right-click the folder in windows
explorer, choose Security and assign Modify permissions to the users of
the database. Who the users that need permissions are depends on how
your website is configured to authenticate:
Anonymous means the aspnet account is the user
Integrated with Anonymous disabled means the network user is the user

I have no website on mvps.org
BD wrote:
> 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@NOyahoo.SPAMcom> wrote in message
> news:%23vR469EsIHA.2064@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.



Re: New problem by Mike

Mike
Fri May 09 14:51:28 CDT 2008

Not really wanting to encourage ASP.NET questions and answers here (but
since it has been started), the default user on XP Pro is ASPNET, whereas
it's NETWORK SERVICE on Win2k3.

You can find various samples showing Access in use with ADO.NET code here:
www.mikesdotnetting.com. Feel free to post further Access and ASP.NET
related questions here: http://forums.asp.net/55.aspx

--
Mike Brind
Microsoft MVP ASP/ASP.NET

"BD" <JustMe@nothome.net> wrote in message
news:OMlgcSFsIHA.5000@TK2MSFTNGP04.phx.gbl...
> 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@NOyahoo.SPAMcom> wrote in message
> news:%23vR469EsIHA.2064@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.
>>
>>
>
>