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 a .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
(traditional) 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 .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 .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 .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.
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 a .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
(traditional) 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 .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 .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 .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.