Saturday, March 24, 2012

Operation must use an updateable query.

The folder that contains the database (.mdb) file must have MODIFY
permission granted to the user account under which ASP.Net is running.
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
"Pravin A. Sable" <pravin@dotnet.itags.org.ccs.neu.edu> wrote in message
news:#tUTTnULEHA.556@dotnet.itags.org.TK2MSFTNGP10.phx.gbl...
> Dear All,
>
> Please find the source code for this error in attachment.
> I am trying to execute following code
> Sub SubmitBtn_Click(ByVal Sender As Object, ByVal E As EventArgs)
> Dim DBConn As OleDbConnection
> Dim DBInsert As New OleDbCommand
> DBConn = New OleDbConnection("PROVIDER=" _
> & "Microsoft.Jet.OLEDB.4.0;" _
> & "DATA SOURCE=" _
> & Server.MapPath("Emps.mdb;"))
> DBInsert.CommandText = "Insert Into Employees " _
> & "(LastName, FirstName, PhoneNumber, EmailAddress, " _
> & "Notes, DepartmentID) values (" _
> & "'" & Replace(txtLastName.Text, "'", "''") & "', " _
> & "'" & Replace(txtFirstName.Text, "'", "''") & "', " _
> & "'" & Replace(txtPhoneNumber.Text, "'", "''") & "', " _
> & "'" & Replace(txtEmailAddress.Text, "'", "''") _
> & "', " _
> & "'" & Replace(txtNotes.Text, "'", "''") & "', " _
> & ddlDepartments.SelectedItem.Value & ")"
> DBInsert.Connection = DBConn
> DBInsert.Connection.Open()
> DBInsert.ExecuteNonQuery()
> Response.Redirect("./index.aspx")
> End Sub
> while executing following
> DBInsert.ExecuteNonQuery()
> query is
> Insert Into Employees (LastName, FirstName, PhoneNumber, EmailAddress,
> Notes, DepartmentID) values ('asdfas', 'asdf', 'asdfasfdasdf', 'asf',
> 'asdfasdf', 3)
>
> I get an error saying as follows, Whats happening... it's new to me..
> more to that its an example striaght copy paste from one book.
>
> Operation must use an updateable query.
> Description: An unhandled exception occurred during the execution of the
> current web request. Please review the stack trace for more information
> about the error and where it originated in the code.
> Exception Details: System.Data.OleDb.OleDbException: Operation must use
> an updateable query.
> Source Error:
>
> Line 58: DBInsert.Connection = DBConn
> Line 59: DBInsert.Connection.Open()
> Line 60: DBInsert.ExecuteNonQuery()
> Line 61: Response.Redirect("./index.aspx")
> Line 62: End Sub
>
> Source File: c:\inetpub\wwwroot\WebApplication1\add1.aspx.vb Line: 60
> Stack Trace:
>
> [OleDbException (0x80004005): Operation must use an updateable query.]
> System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(Int32
hr)
>
System.Data.OleDb.OleDbCommand. ExecuteCommandTextForSingleResult(tagDBP
ARAMS
> dbParams, Object& executeResult)
> System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object&
executeResult)
> System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior
> behavior, Object& executeResult)
> System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior
> behavior, String method)
> System.Data.OleDb.OleDbCommand.ExecuteNonQuery()
> WebApplication1.add1.SubmitBtn_Click(Object Sender, EventArgs E) in
> c:\inetpub\wwwroot\WebApplication1\add1.aspx.vb:60
> System.Web.UI.WebControls.Button.OnClick(EventArgs e)
>
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePo
stBackEvent(String
> eventArgument)
> System.Web.UI.Page. RaisePostBackEvent(IPostBackEventHandler
> sourceControl, String eventArgument)
> System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
> System.Web.UI.Page.ProcessRequestMain()
>
>I gave administrative privileges for ASP.net user, the folder is in
Inetpub/wwwroot/web application1. Folder remains read only. but database
has permission to change. The problem comes between these lines
DBInsert.Connection.Open()
'Above statement makes the database read only.
DBInsert.ExecuteNonQuery()
'Above statemet gives an error
Alphonse Giambrone wrote:
> I just ran into this one a few days ago.
> You need to have write permission for the database file/folder.
>Please find the source code for this error in attachment.
hr)
System.Data.OleDb.OleDbCommand. ExecuteCommandTextForSingleResult(tagDBP
ARAMS
executeResult)
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePo
stBackEvent(String
You also need to set the permission via Windows Explorer not just IIS.
Alphonse Giambrone
Email: a-giam at customdatasolutions dot us
"Pravin A. Sable" <pravin@.ccs.neu.edu> wrote in message
news:%237qL6FVLEHA.4052@.TK2MSFTNGP11.phx.gbl...
> I gave administrative privileges for ASP.net user, the folder is in
> Inetpub/wwwroot/web application1. Folder remains read only. but database
> has permission to change. The problem comes between these lines
> DBInsert.Connection.Open()
> 'Above statement makes the database read only.
> DBInsert.ExecuteNonQuery()
> 'Above statemet gives an error
> Alphonse Giambrone wrote:
the
information
use
60
System.Data.OleDb.OleDbCommand. ExecuteCommandTextErrorHandling(Int32[co
lor=darkred]
> hr)
>
>
System.Data.OleDb.OleDbCommand. ExecuteCommandTextForSingleResult(tagDBP
ARAMS
>
> executeResult)
>
System.Data.OleDb.OleDbCommand. ExecuteReaderInternal(CommandBehavior[co
lor=darkred]
in
>
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePo
> stBackEvent(String
>
postData)
I tried seeting up permission through windows explorer for folder. it
reverts back to read only. but I am not sure that is the issue, when
connection is open, the database becomes read-only. May be database is
opened in read-only mode and it is locked hence no query can be
executed. Still I am stuck any help is appreciated.
Alphonse Giambrone wrote:

> You also need to set the permission via Windows Explorer not just IIS.
>
It's a WinXP machine. I don't option to set permission for modify etc. I
can just make user a limited user or administrator. I have made all the
users administrator. What else should I do?
Kevin Spencer wrote:

> The folder that contains the database (.mdb) file must have MODIFY
> permission granted to the user account under which ASP.Net is running.
>
Hi Pravin A. Sable,
Check the properties of the emps.mdb go to security tab and try adding the
aspnet user and give proper rights.
HTH
Regards
Ashish M Bhonkiya
"Pravin A. Sable" <pravin@.ccs.neu.edu> wrote in message
news:%23tUTTnULEHA.556@.TK2MSFTNGP10.phx.gbl...
> Dear All,
>
> Please find the source code for this error in attachment.
> I am trying to execute following code
> Sub SubmitBtn_Click(ByVal Sender As Object, ByVal E As EventArgs)
> Dim DBConn As OleDbConnection
> Dim DBInsert As New OleDbCommand
> DBConn = New OleDbConnection("PROVIDER=" _
> & "Microsoft.Jet.OLEDB.4.0;" _
> & "DATA SOURCE=" _
> & Server.MapPath("Emps.mdb;"))
> DBInsert.CommandText = "Insert Into Employees " _
> & "(LastName, FirstName, PhoneNumber, EmailAddress, " _
> & "Notes, DepartmentID) values (" _
> & "'" & Replace(txtLastName.Text, "'", "''") & "', " _
> & "'" & Replace(txtFirstName.Text, "'", "''") & "', " _
> & "'" & Replace(txtPhoneNumber.Text, "'", "''") & "', " _
> & "'" & Replace(txtEmailAddress.Text, "'", "''") _
> & "', " _
> & "'" & Replace(txtNotes.Text, "'", "''") & "', " _
> & ddlDepartments.SelectedItem.Value & ")"
> DBInsert.Connection = DBConn
> DBInsert.Connection.Open()
> DBInsert.ExecuteNonQuery()
> Response.Redirect("./index.aspx")
> End Sub
> while executing following
> DBInsert.ExecuteNonQuery()
> query is
> Insert Into Employees (LastName, FirstName, PhoneNumber, EmailAddress,
> Notes, DepartmentID) values ('asdfas', 'asdf', 'asdfasfdasdf', 'asf',
> 'asdfasdf', 3)
>
> I get an error saying as follows, Whats happening... it's new to me..
> more to that its an example striaght copy paste from one book.
>
> Operation must use an updateable query.
> Description: An unhandled exception occurred during the execution of the
> current web request. Please review the stack trace for more information
> about the error and where it originated in the code.
> Exception Details: System.Data.OleDb.OleDbException: Operation must use
> an updateable query.
> Source Error:
>
> Line 58: DBInsert.Connection = DBConn
> Line 59: DBInsert.Connection.Open()
> Line 60: DBInsert.ExecuteNonQuery()
> Line 61: Response.Redirect("./index.aspx")
> Line 62: End Sub
>
> Source File: c:\inetpub\wwwroot\WebApplication1\add1.aspx.vb Line: 60
> Stack Trace:
>
> [OleDbException (0x80004005): Operation must use an updateable query.]
> System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(Int32
hr)
>
System.Data.OleDb.OleDbCommand. ExecuteCommandTextForSingleResult(tagDBP
ARAMS
> dbParams, Object& executeResult)
> System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object&
executeResult)
> System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior
> behavior, Object& executeResult)
> System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior
> behavior, String method)
> System.Data.OleDb.OleDbCommand.ExecuteNonQuery()
> WebApplication1.add1.SubmitBtn_Click(Object Sender, EventArgs E) in
> c:\inetpub\wwwroot\WebApplication1\add1.aspx.vb:60
> System.Web.UI.WebControls.Button.OnClick(EventArgs e)
>
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePo
stBackEvent(String
> eventArgument)
> System.Web.UI.Page. RaisePostBackEvent(IPostBackEventHandler
> sourceControl, String eventArgument)
> System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
> System.Web.UI.Page.ProcessRequestMain()
>
>
Sounds like you need to disable Simplified File Sharing on your machine to
see the Security tab. The following MS article tells you how:
http://support.microsoft.com/default.aspx?kbid=307874
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
"Pravin A. Sable" <pravin@.ccs.neu.edu> wrote in message
news:u5er$sXLEHA.3472@.TK2MSFTNGP09.phx.gbl...
> It's a WinXP machine. I don't option to set permission for modify etc. I
> can just make user a limited user or administrator. I have made all the
> users administrator. What else should I do?
> Kevin Spencer wrote:
>
Pravin,
Kevin is correct. That is the exact problem I ran into. Turning off simple
file sharing adds the security tab to the properties for the folder and
file. You can then set permissions for the asp.net account.
Alphonse Giambrone
Email: a-giam at customdatasolutions dot us
"Pravin A. Sable" <pravin@.ccs.neu.edu> wrote in message
news:u5er$sXLEHA.3472@.TK2MSFTNGP09.phx.gbl...
> It's a WinXP machine. I don't option to set permission for modify etc. I
> can just make user a limited user or administrator. I have made all the
> users administrator. What else should I do?
> Kevin Spencer wrote:
>
I just ran into this one a few days ago.
You need to have write permission for the database file/folder.
Alphonse Giambrone
Email: a-giam at customdatasolutions dot us
"Pravin A. Sable" <pravin@.ccs.neu.edu> wrote in message
news:%23tUTTnULEHA.556@.TK2MSFTNGP10.phx.gbl...
> Dear All,
>
> Please find the source code for this error in attachment.
> I am trying to execute following code
> Sub SubmitBtn_Click(ByVal Sender As Object, ByVal E As EventArgs)
> Dim DBConn As OleDbConnection
> Dim DBInsert As New OleDbCommand
> DBConn = New OleDbConnection("PROVIDER=" _
> & "Microsoft.Jet.OLEDB.4.0;" _
> & "DATA SOURCE=" _
> & Server.MapPath("Emps.mdb;"))
> DBInsert.CommandText = "Insert Into Employees " _
> & "(LastName, FirstName, PhoneNumber, EmailAddress, " _
> & "Notes, DepartmentID) values (" _
> & "'" & Replace(txtLastName.Text, "'", "''") & "', " _
> & "'" & Replace(txtFirstName.Text, "'", "''") & "', " _
> & "'" & Replace(txtPhoneNumber.Text, "'", "''") & "', " _
> & "'" & Replace(txtEmailAddress.Text, "'", "''") _
> & "', " _
> & "'" & Replace(txtNotes.Text, "'", "''") & "', " _
> & ddlDepartments.SelectedItem.Value & ")"
> DBInsert.Connection = DBConn
> DBInsert.Connection.Open()
> DBInsert.ExecuteNonQuery()
> Response.Redirect("./index.aspx")
> End Sub
> while executing following
> DBInsert.ExecuteNonQuery()
> query is
> Insert Into Employees (LastName, FirstName, PhoneNumber, EmailAddress,
> Notes, DepartmentID) values ('asdfas', 'asdf', 'asdfasfdasdf', 'asf',
> 'asdfasdf', 3)
>
> I get an error saying as follows, Whats happening... it's new to me..
> more to that its an example striaght copy paste from one book.
>
> Operation must use an updateable query.
> Description: An unhandled exception occurred during the execution of the
> current web request. Please review the stack trace for more information
> about the error and where it originated in the code.
> Exception Details: System.Data.OleDb.OleDbException: Operation must use
> an updateable query.
> Source Error:
>
> Line 58: DBInsert.Connection = DBConn
> Line 59: DBInsert.Connection.Open()
> Line 60: DBInsert.ExecuteNonQuery()
> Line 61: Response.Redirect("./index.aspx")
> Line 62: End Sub
>
> Source File: c:\inetpub\wwwroot\WebApplication1\add1.aspx.vb Line: 60
> Stack Trace:
>
> [OleDbException (0x80004005): Operation must use an updateable query.]
> System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(Int32
hr)
>
System.Data.OleDb.OleDbCommand. ExecuteCommandTextForSingleResult(tagDBP
ARAMS
> dbParams, Object& executeResult)
> System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object&
executeResult)
> System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior
> behavior, Object& executeResult)
> System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior
> behavior, String method)
> System.Data.OleDb.OleDbCommand.ExecuteNonQuery()
> WebApplication1.add1.SubmitBtn_Click(Object Sender, EventArgs E) in
> c:\inetpub\wwwroot\WebApplication1\add1.aspx.vb:60
> System.Web.UI.WebControls.Button.OnClick(EventArgs e)
>
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePo
stBackEvent(String
> eventArgument)
> System.Web.UI.Page. RaisePostBackEvent(IPostBackEventHandler
> sourceControl, String eventArgument)
> System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
> System.Web.UI.Page.ProcessRequestMain()
>
>

0 comments:

Post a Comment