Your code is not the problem.
a) move the database out of the www folders unless you have a compelling
need for it to be there.
b) you don't have to create the aspnet user. It already exists. Your web
app is running as the aspnet user unless you change this fact using the
impersonate tag in the web.config. The Name of the aspnet user varies
depending on which version of the OS (and therefore, which version of IIS)
you are using. The account name usually has a prefix of ASPNET.
The step-by-step in in the walkthrough link I provided at the location I
described.
I copied the instructions here, since it appears that you have not read the
article:
------------------------ copied from MSDN article ---------------------
In this walkthrough you will use the third (and safest) method to grant
write permission.
1.. From the File Explorer, find the new Pets folder, normally located at
C:\Inetpub\wwwroot\Pets\Pets.
2.. Right-click the Pets folder, and select Properties.
3.. Select the Security tab, and click the Add button.
4.. Add the object name <YOURMACHINE>\ASPNET where <YOURMACHINE> is the
name of your machine. Click OK to return to the Security tab.
5.. Select the ASP.NET account, and add Write permission. This account is
named aspnet_wp account, ASP.NET MACHINE Account, or something similar.
6.. From the File Explorer, right-click the file Pets.mdb, and select
Properties.
7.. Select the Security tab, and click the Advanced button.
8.. Check "Inherit from parent the permissions entries that apply to child
objects". Click OK to accept the change.
-----------------------------------------
Hope this helps,
--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik
Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"sambuela" <sa******@discussions.microsoft.com> wrote in message
news:B2**********************************@microsof t.com...
Thanks for your information and suggestion.
However, I still don't know how to creat a asp.net user before grant it
to my folder. Currently, I still cannot write record to the file and
Access
DB.
Can you instrutct me to do so and review my previous code? thanks.
Best Regards,
--sambuela
"Nick Malik [Microsoft]" wrote:
Try reading this walkthrough:
Editing an Access Database with ADO.Net
http://msdn.microsoft.com/library/de...wtaccessdb.asp
look for the section that starts: "The ASP.NET user, by default, does not
have permission to write a record to a database or create a locking file
(.ldb) in the folder containing the database. You must give the ASP.NET
user
these permissions."
I wonder why you are placing your access database into a web folder? You
run into security issues that way. Any reason you shouldn't place the
access db under a seperate folder like C:/MyApplication ?
--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik
Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"sambuela" <sa******@discussions.microsoft.com> wrote in message
news:30**********************************@microsof t.com... > This is my source code:
>
> <%@ Import Namespace="System.IO" %>
> <%@ Import Namespace="System"%>
> <html>
> <head><title>Write to file</title>
> </head>
> <body>
> <%
> Dim txtWriter As StreamWriter
> txtWriter = File.CreateText(Server.MapPath("Hello.txt"))
> txtWriter = New StreamWriter("Hello.txt")
> txtWriter.WriteLine("Hi")
> txtWriter.Close
> Response.Write(" 'Hello.txt'was built sucessfully ")
> %>
>
> Regards,
> --sambuela
>
> "sambuela" wrote:
>
>>
>> How can I write message to the file located in the wwwroot directory?
>> It seems that IIS protect these files.
>> Let make me cannot do the I/O writing sucessfully.
>> I try to open file's write privileage by file manager and IIS manager.
>> However, one PC is okay and another PC is not.
>>
>> Any help on this will be greatly appreciated.
>> Regards,
>> --sambuela