473,412 Members | 2,072 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,412 software developers and data experts.

Must use updateable query?

Continuing my lessons out of a book, I ran into a problem when trying for
the first time to update a datastore (access database in this case).

My Code:

Private Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
Dim strConnection, strSQL As String
Dim objDataSet As New DataSet()
Dim objConnection As OleDbConnection
Dim objAdapter As OleDbDataAdapter

strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=e:\hhsinternal\comlog\testing.mdb"
strSQL = "SELECT tmasterid, firstname, lastname from tmaster;"

objConnection = New OleDbConnection(strConnection)
objAdapter = New OleDbDataAdapter(strSQL, objConnection)

objAdapter.Fill(objDataSet, "tmaster")

dglist1.DataSource = objDataSet.Tables("tmaster")
dglist1.DataBind()

Dim objTable As DataTable
Dim objNewRow As DataRow

objTable = objDataSet.Tables("tmaster")
objNewRow = objTable.NewRow()
objNewRow("FirstName") = "Pepsi"
objNewRow("LastName") = "Cola"
objTable.Rows.Add(objNewRow)

dglist2.DataSource = objTable.DefaultView
dglist2.DataBind()

Dim objRow As DataRow
objRow = objTable.Rows(3)
objRow("FirstName") = "Coca"
objRow("LastName") = "Cola"

dglist3.DataSource = objTable.DefaultView
dglist3.DataBind()

objTable.Rows(objTable.Rows.Count - 2).Delete()

dglist4.DataSource = objTable.DefaultView
dglist4.DataBind()

Dim objBuilder As OleDbCommandBuilder
objBuilder = New OleDbCommandBuilder(objAdapter)
objAdapter.UpdateCommand = objBuilder.GetUpdateCommand()
objAdapter.InsertCommand = objBuilder.GetInsertCommand()
objAdapter.DeleteCommand = objBuilder.GetDeleteCommand()

objAdapter.Update(objDataSet, "tmaster")

strSQL = "SELECT tmasterid, firstname, lastname from tmaster;"
objConnection.Open()
Dim objCmd As New OleDbCommand(strSQL, objConnection)
dgUpd.DataSource =
objCmd.ExecuteReader(CommandBehavior.CloseConnecti on)
dgUpd.DataBind()

End Sub

And .. The Horrible Error!! Line 55 is where the error is.

Server Error in '/' Application.
--------------------------------------------------------------------------------

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 53: objAdapter.DeleteCommand = objBuilder.GetDeleteCommand()
Line 54:
Line 55: objAdapter.Update(objDataSet, "tmaster")
Line 56:
Line 57: strSQL = "SELECT tmasterid, firstname, lastname from
tmaster;"
Source File: E:\hhsinternal\comlog\synch2.aspx.vb Line: 55

Stack Trace:
[OleDbException (0x80004005): Operation must use an updateable query.]
System.Data.Common.DbDataAdapter.UpdatedRowStatusE rrors(RowUpdatedEventArgs
rowUpdatedEvent, BatchCommandInfo[] batchCommands, Int32 commandCount) +277
System.Data.Common.DbDataAdapter.UpdatedRowStatus( RowUpdatedEventArgs
rowUpdatedEvent, BatchCommandInfo[] batchCommands, Int32 commandCount) +48
System.Data.Common.DbDataAdapter.Update(DataRow[] dataRows,
DataTableMapping tableMapping) +1802
System.Data.Common.DbDataAdapter.UpdateFromDataTab le(DataTable dataTable,
DataTableMapping tableMapping) +38
System.Data.Common.DbDataAdapter.Update(DataSet dataSet, String srcTable)
+166
synch2_aspx.Page_Load(Object sender, EventArgs e) in
E:\hhsinternal\comlog\synch2.aspx.vb:55
System.Web.UI.Control.OnLoad(EventArgs e) +102
System.Web.UI.Control.LoadRecursive() +45
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +952

--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.40607.42; ASP.NET
Version:2.0.40607.42
Nov 19 '05 #1
4 2914
This error usually occurs when the folder containing the database file does
not have the proper file permissions to allow the ASP.Net user account to
change or write to the folder. Inserts, Updates, and Deletes change the
file.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Ambiguity has a certain quality to it.

"Jim in Arizona" <ti*******@hotmail.com> wrote in message
news:eH**************@TK2MSFTNGP09.phx.gbl...
Continuing my lessons out of a book, I ran into a problem when trying for
the first time to update a datastore (access database in this case).

My Code:

Private Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
Dim strConnection, strSQL As String
Dim objDataSet As New DataSet()
Dim objConnection As OleDbConnection
Dim objAdapter As OleDbDataAdapter

strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=e:\hhsinternal\comlog\testing.mdb"
strSQL = "SELECT tmasterid, firstname, lastname from tmaster;"

objConnection = New OleDbConnection(strConnection)
objAdapter = New OleDbDataAdapter(strSQL, objConnection)

objAdapter.Fill(objDataSet, "tmaster")

dglist1.DataSource = objDataSet.Tables("tmaster")
dglist1.DataBind()

Dim objTable As DataTable
Dim objNewRow As DataRow

objTable = objDataSet.Tables("tmaster")
objNewRow = objTable.NewRow()
objNewRow("FirstName") = "Pepsi"
objNewRow("LastName") = "Cola"
objTable.Rows.Add(objNewRow)

dglist2.DataSource = objTable.DefaultView
dglist2.DataBind()

Dim objRow As DataRow
objRow = objTable.Rows(3)
objRow("FirstName") = "Coca"
objRow("LastName") = "Cola"

dglist3.DataSource = objTable.DefaultView
dglist3.DataBind()

objTable.Rows(objTable.Rows.Count - 2).Delete()

dglist4.DataSource = objTable.DefaultView
dglist4.DataBind()

Dim objBuilder As OleDbCommandBuilder
objBuilder = New OleDbCommandBuilder(objAdapter)
objAdapter.UpdateCommand = objBuilder.GetUpdateCommand()
objAdapter.InsertCommand = objBuilder.GetInsertCommand()
objAdapter.DeleteCommand = objBuilder.GetDeleteCommand()

objAdapter.Update(objDataSet, "tmaster")

strSQL = "SELECT tmasterid, firstname, lastname from tmaster;"
objConnection.Open()
Dim objCmd As New OleDbCommand(strSQL, objConnection)
dgUpd.DataSource =
objCmd.ExecuteReader(CommandBehavior.CloseConnecti on)
dgUpd.DataBind()

End Sub

And .. The Horrible Error!! Line 55 is where the error is.

Server Error in '/' Application.
--------------------------------------------------------------------------------

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 53: objAdapter.DeleteCommand = objBuilder.GetDeleteCommand()
Line 54:
Line 55: objAdapter.Update(objDataSet, "tmaster")
Line 56:
Line 57: strSQL = "SELECT tmasterid, firstname, lastname from
tmaster;"
Source File: E:\hhsinternal\comlog\synch2.aspx.vb Line: 55

Stack Trace:
[OleDbException (0x80004005): Operation must use an updateable query.]

System.Data.Common.DbDataAdapter.UpdatedRowStatusE rrors(RowUpdatedEventArgs
rowUpdatedEvent, BatchCommandInfo[] batchCommands, Int32 commandCount)
+277
System.Data.Common.DbDataAdapter.UpdatedRowStatus( RowUpdatedEventArgs
rowUpdatedEvent, BatchCommandInfo[] batchCommands, Int32 commandCount) +48
System.Data.Common.DbDataAdapter.Update(DataRow[] dataRows,
DataTableMapping tableMapping) +1802
System.Data.Common.DbDataAdapter.UpdateFromDataTab le(DataTable
dataTable, DataTableMapping tableMapping) +38
System.Data.Common.DbDataAdapter.Update(DataSet dataSet, String
srcTable) +166
synch2_aspx.Page_Load(Object sender, EventArgs e) in
E:\hhsinternal\comlog\synch2.aspx.vb:55
System.Web.UI.Control.OnLoad(EventArgs e) +102
System.Web.UI.Control.LoadRecursive() +45
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +952

--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.40607.42;
ASP.NET Version:2.0.40607.42

Nov 19 '05 #2
At first pass, I'd check out this block:

Dim objRow As DataRow
objRow = objTable.Rows(3)
objRow("FirstName") = "Coca"
objRow("LastName") = "Cola"

and this:
objTable.Rows(objTable.Rows.Count - 2).Delete()

While I dont know how many rows you are expecting in the original query,
if the rowcount is less than the ordinal number of the row youre
trying to delete, then you'll get an error.

Jim in Arizona wrote:
Continuing my lessons out of a book, I ran into a problem when trying for
the first time to update a datastore (access database in this case).

My Code:

Private Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
Dim strConnection, strSQL As String
Dim objDataSet As New DataSet()
Dim objConnection As OleDbConnection
Dim objAdapter As OleDbDataAdapter

strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=e:\hhsinternal\comlog\testing.mdb"
strSQL = "SELECT tmasterid, firstname, lastname from tmaster;"

objConnection = New OleDbConnection(strConnection)
objAdapter = New OleDbDataAdapter(strSQL, objConnection)

objAdapter.Fill(objDataSet, "tmaster")

dglist1.DataSource = objDataSet.Tables("tmaster")
dglist1.DataBind()

Dim objTable As DataTable
Dim objNewRow As DataRow

objTable = objDataSet.Tables("tmaster")
objNewRow = objTable.NewRow()
objNewRow("FirstName") = "Pepsi"
objNewRow("LastName") = "Cola"
objTable.Rows.Add(objNewRow)

dglist2.DataSource = objTable.DefaultView
dglist2.DataBind()

Dim objRow As DataRow
objRow = objTable.Rows(3)
objRow("FirstName") = "Coca"
objRow("LastName") = "Cola"

dglist3.DataSource = objTable.DefaultView
dglist3.DataBind()

objTable.Rows(objTable.Rows.Count - 2).Delete()

dglist4.DataSource = objTable.DefaultView
dglist4.DataBind()

Dim objBuilder As OleDbCommandBuilder
objBuilder = New OleDbCommandBuilder(objAdapter)
objAdapter.UpdateCommand = objBuilder.GetUpdateCommand()
objAdapter.InsertCommand = objBuilder.GetInsertCommand()
objAdapter.DeleteCommand = objBuilder.GetDeleteCommand()

objAdapter.Update(objDataSet, "tmaster")

strSQL = "SELECT tmasterid, firstname, lastname from tmaster;"
objConnection.Open()
Dim objCmd As New OleDbCommand(strSQL, objConnection)
dgUpd.DataSource =
objCmd.ExecuteReader(CommandBehavior.CloseConnecti on)
dgUpd.DataBind()

End Sub

And .. The Horrible Error!! Line 55 is where the error is.

Server Error in '/' Application.
--------------------------------------------------------------------------------

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 53: objAdapter.DeleteCommand = objBuilder.GetDeleteCommand()
Line 54:
Line 55: objAdapter.Update(objDataSet, "tmaster")
Line 56:
Line 57: strSQL = "SELECT tmasterid, firstname, lastname from
tmaster;"
Source File: E:\hhsinternal\comlog\synch2.aspx.vb Line: 55

Stack Trace:
[OleDbException (0x80004005): Operation must use an updateable query.]
System.Data.Common.DbDataAdapter.UpdatedRowStatusE rrors(RowUpdatedEventArgs
rowUpdatedEvent, BatchCommandInfo[] batchCommands, Int32 commandCount) +277
System.Data.Common.DbDataAdapter.UpdatedRowStatus( RowUpdatedEventArgs
rowUpdatedEvent, BatchCommandInfo[] batchCommands, Int32 commandCount) +48
System.Data.Common.DbDataAdapter.Update(DataRow[] dataRows,
DataTableMapping tableMapping) +1802
System.Data.Common.DbDataAdapter.UpdateFromDataTab le(DataTable dataTable,
DataTableMapping tableMapping) +38
System.Data.Common.DbDataAdapter.Update(DataSet dataSet, String srcTable)
+166
synch2_aspx.Page_Load(Object sender, EventArgs e) in
E:\hhsinternal\comlog\synch2.aspx.vb:55
System.Web.UI.Control.OnLoad(EventArgs e) +102
System.Web.UI.Control.LoadRecursive() +45
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +952

--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.40607.42; ASP.NET
Version:2.0.40607.42

Nov 19 '05 #3

"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:uN**************@TK2MSFTNGP12.phx.gbl...
This error usually occurs when the folder containing the database file
does not have the proper file permissions to allow the ASP.Net user
account to change or write to the folder. Inserts, Updates, and Deletes
change the file.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
Ambiguity has a certain quality to it.


That appeard to be the problem. Thanks Kevin.
Jim
Nov 19 '05 #4
That also occured to me so I double check it and found it to be ok.

Thanks Elliot.
Jim

"Elliot M. Rodriguez" <"elliotrodriguez[spamminyspam]"@gmail.com> wrote in
message news:eF**************@TK2MSFTNGP12.phx.gbl...
At first pass, I'd check out this block:

Dim objRow As DataRow
objRow = objTable.Rows(3)
objRow("FirstName") = "Coca"
objRow("LastName") = "Cola"

and this:
objTable.Rows(objTable.Rows.Count - 2).Delete()

While I dont know how many rows you are expecting in the original query,
if the rowcount is less than the ordinal number of the row youre trying to
delete, then you'll get an error.

Jim in Arizona wrote:
Continuing my lessons out of a book, I ran into a problem when trying for
the first time to update a datastore (access database in this case).

My Code:

Private Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
Dim strConnection, strSQL As String
Dim objDataSet As New DataSet()
Dim objConnection As OleDbConnection
Dim objAdapter As OleDbDataAdapter

strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=e:\hhsinternal\comlog\testing.mdb"
strSQL = "SELECT tmasterid, firstname, lastname from tmaster;"

objConnection = New OleDbConnection(strConnection)
objAdapter = New OleDbDataAdapter(strSQL, objConnection)

objAdapter.Fill(objDataSet, "tmaster")

dglist1.DataSource = objDataSet.Tables("tmaster")
dglist1.DataBind()

Dim objTable As DataTable
Dim objNewRow As DataRow

objTable = objDataSet.Tables("tmaster")
objNewRow = objTable.NewRow()
objNewRow("FirstName") = "Pepsi"
objNewRow("LastName") = "Cola"
objTable.Rows.Add(objNewRow)

dglist2.DataSource = objTable.DefaultView
dglist2.DataBind()

Dim objRow As DataRow
objRow = objTable.Rows(3)
objRow("FirstName") = "Coca"
objRow("LastName") = "Cola"

dglist3.DataSource = objTable.DefaultView
dglist3.DataBind()

objTable.Rows(objTable.Rows.Count - 2).Delete()

dglist4.DataSource = objTable.DefaultView
dglist4.DataBind()

Dim objBuilder As OleDbCommandBuilder
objBuilder = New OleDbCommandBuilder(objAdapter)
objAdapter.UpdateCommand = objBuilder.GetUpdateCommand()
objAdapter.InsertCommand = objBuilder.GetInsertCommand()
objAdapter.DeleteCommand = objBuilder.GetDeleteCommand()

objAdapter.Update(objDataSet, "tmaster")

strSQL = "SELECT tmasterid, firstname, lastname from tmaster;"
objConnection.Open()
Dim objCmd As New OleDbCommand(strSQL, objConnection)
dgUpd.DataSource =
objCmd.ExecuteReader(CommandBehavior.CloseConnecti on)
dgUpd.DataBind()

End Sub

And .. The Horrible Error!! Line 55 is where the error is.

Server Error in '/' Application.
--------------------------------------------------------------------------------

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 53: objAdapter.DeleteCommand = objBuilder.GetDeleteCommand()
Line 54:
Line 55: objAdapter.Update(objDataSet, "tmaster")
Line 56:
Line 57: strSQL = "SELECT tmasterid, firstname, lastname from
tmaster;"
Source File: E:\hhsinternal\comlog\synch2.aspx.vb Line: 55

Stack Trace:
[OleDbException (0x80004005): Operation must use an updateable query.]

System.Data.Common.DbDataAdapter.UpdatedRowStatusE rrors(RowUpdatedEventArgs
rowUpdatedEvent, BatchCommandInfo[] batchCommands, Int32 commandCount)
+277
System.Data.Common.DbDataAdapter.UpdatedRowStatus( RowUpdatedEventArgs
rowUpdatedEvent, BatchCommandInfo[] batchCommands, Int32 commandCount)
+48
System.Data.Common.DbDataAdapter.Update(DataRow[] dataRows,
DataTableMapping tableMapping) +1802
System.Data.Common.DbDataAdapter.UpdateFromDataTab le(DataTable
dataTable, DataTableMapping tableMapping) +38
System.Data.Common.DbDataAdapter.Update(DataSet dataSet, String
srcTable) +166
synch2_aspx.Page_Load(Object sender, EventArgs e) in
E:\hhsinternal\comlog\synch2.aspx.vb:55
System.Web.UI.Control.OnLoad(EventArgs e) +102
System.Web.UI.Control.LoadRecursive() +45
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +952

--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.40607.42;
ASP.NET Version:2.0.40607.42

Nov 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Tom wilson | last post by:
This is driving me nuts. I'm trying to update an Excel spreadsheet using ADO.Net and Oledb in VB.Net. The connection is open, the adapter is connected and the dataset is loaded. Here's the code...
6
by: ano1optimist | last post by:
I have been running these queries in Access 2000 with no problems. This week, I had to install Access 2003 to create some runtime versions for another application, and now I keep getting "operation...
4
by: MDW | last post by:
Hey all. I'm confused. I'm trying to add a single record into an Access 2000 database using ASP.Net. Here is the code: objConn = New OleDbConnection(strConnect) objConn.Open objCommand =...
606
by: Neil Zanella | last post by:
Hello, I am trying to update an MS access database from ASP.NET. I am using IIS on Windows XP Pro. I can issue SELECT statements from ASP.NET using ADO.NET but I cannot seem to be able to carry...
2
by: SheryMich | last post by:
Hi - I am having a bit of a problem with the insert into a database. When I go to insert a record into an un-keyed, single table Access database, I get the aforementioned ''Operation Must Use an...
5
by: Web Search Store | last post by:
I'm getting this error on my web page: Error Type: Microsoft OLE DB Provider for ODBC Drivers (0x80004005) Operation must use an updateable query. /searchweb33.asp, line 5014 Here is the...
8
by: Jim in Arizona | last post by:
I've been using an example out of a book to be able to edit the rows in a database. I am getting the following error: ========================================================...
11
by: Arpan | last post by:
I have always been working with SQL Server 2005 for ASP.NET apps but due to some reasons, had to revert back to MS-Access 2000. When I try to insert/update a MS-Access DB table (MDB), ASP.NET...
1
by: pavya | last post by:
Hi, I have developed one Web application. At that time my system had a FAT file system on it and this application worked properly. But now i have converted FAT file system to NTFS file system and...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.