Database restrictions from ASP.NET???

L

Luis

Hello,

I am a newbie in .NET and Visual Studio, I come from the Java
environment. I am developing my first .NET app and have found a big
stopper, I hope you can help me out of it.

I have defined an MS Access database with a test table (MS Access 2002
version). From an ASP.NET application I can easily read its data and
display it in a DataGrid. The problem arises when I try to UPDATE that
table: I get an OleDbException (0x80004005): "the operation must use
an updateable query" (the original exception text is in Spanish so the
English message is probably different, but the number should be the
same).

The update command is correct since it works fine when executed from a
client-side windows application. When I copy&paste the exact same
code inside a Page_Load method, I get the above exception.

To check if it was a file-write permission restriction, I have also
tested writing a "hello.txt" file to the same directory, and it has
worked fine even from the ASP.NET application. I have also enabled all
read and write permissions from the IIS configuration properties.

So I am lost... Is there some restriction with MDB databases or OLEDB
from within ASP.NET applications? If so, how can I overcome that
restriction? Or, is there some other reason why the exact same code
should work in a windows application and fail in a ASP.NET one?

In case you want to check, this is the code I am using. The table and
column names are in Spanish but that should not be a problem, it is a
simple "persons" data table:


Dim sql As String
Dim insertCmd As OleDbCommand
Dim connStr As String
Dim conn As OleDbConnection

connStr = "Provider=Microsoft.Jet.OLEDB.4.0; "
connStr = connStr + "Data Source=C:\pepe\prueba.mdb;"
conn = New OleDbConnection(connStr)
sql = "insert into [personas] ([nombre], [apellido], [dni]) values
("
sql = sql + "'Pedro','Pérez','333')"
insertCmd = New OleDbCommand(sql, conn)
conn.Open()
insertCmd.ExecuteNonQuery()
conn.Close()

The exception arises when invoking "insertCmd.ExecuteNonQuery()"...

Thank you very much in advance.

Luis.
 
C

Cor

Hi Luis,

Most regulars in dotnet.general are also active in this newsgroup or visits
both often.

You write there that it works fine with windows forms but not with aspnet.

Than it is mostly an authorisation problem.
Maybe the file/directory has only reading rights on your server for the
aspnet/IIS clients .

You can also ask this question in the asp.net newsgroup, but do us a favor,
crosspost it than (to adonet and general also). And tell the guys and girls
in aspnet, that you could do it with a windowform the same as you did tell
in the dotnet general newsgroups.

I hope this helps

Cor
 
P

Paul Clement

On 25 Mar 2004 14:33:19 -0800, (e-mail address removed) (Luis) wrote:

¤ Hello,
¤
¤ I am a newbie in .NET and Visual Studio, I come from the Java
¤ environment. I am developing my first .NET app and have found a big
¤ stopper, I hope you can help me out of it.
¤
¤ I have defined an MS Access database with a test table (MS Access 2002
¤ version). From an ASP.NET application I can easily read its data and
¤ display it in a DataGrid. The problem arises when I try to UPDATE that
¤ table: I get an OleDbException (0x80004005): "the operation must use
¤ an updateable query" (the original exception text is in Spanish so the
¤ English message is probably different, but the number should be the
¤ same).
¤
¤ The update command is correct since it works fine when executed from a
¤ client-side windows application. When I copy&paste the exact same
¤ code inside a Page_Load method, I get the above exception.
¤
¤ To check if it was a file-write permission restriction, I have also
¤ tested writing a "hello.txt" file to the same directory, and it has
¤ worked fine even from the ASP.NET application. I have also enabled all
¤ read and write permissions from the IIS configuration properties.
¤
¤ So I am lost... Is there some restriction with MDB databases or OLEDB
¤ from within ASP.NET applications? If so, how can I overcome that
¤ restriction? Or, is there some other reason why the exact same code
¤ should work in a windows application and fail in a ASP.NET one?
¤
¤ In case you want to check, this is the code I am using. The table and
¤ column names are in Spanish but that should not be a problem, it is a
¤ simple "persons" data table:
¤
¤
¤ Dim sql As String
¤ Dim insertCmd As OleDbCommand
¤ Dim connStr As String
¤ Dim conn As OleDbConnection
¤
¤ connStr = "Provider=Microsoft.Jet.OLEDB.4.0; "
¤ connStr = connStr + "Data Source=C:\pepe\prueba.mdb;"
¤ conn = New OleDbConnection(connStr)
¤ sql = "insert into [personas] ([nombre], [apellido], [dni]) values
¤ ("
¤ sql = sql + "'Pedro','Pérez','333')"
¤ insertCmd = New OleDbCommand(sql, conn)
¤ conn.Open()
¤ insertCmd.ExecuteNonQuery()
¤ conn.Close()
¤
¤ The exception arises when invoking "insertCmd.ExecuteNonQuery()"...

Check to see whether the corresponding .LDB file is being created when you open the database.
Typically the authenticated user, probably ASPNET in this instance, will need Read, Write, Create
and Delete access to the folder where the database is located.


Paul ~~~ (e-mail address removed)
Microsoft MVP (Visual Basic)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top