472,961 Members | 2,760 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

dataAdapter.Update(data, "TableName") won’t work!

hch

dataAdapter.Update(data, "TableName") won’t work!
I was about to deploy my first website on the Internet only to discover that
the dataAdapter.Update() throws the Server Error in the third underline. It
was working fine before.
ConnectionString in Web.config:
-----------------------------------------
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="ConnectionString" value="Provider=Microsoft.Jet.OLEDB.4.0;Ole DB
Services=-4;Data Source=C:\databases\Resume1.mdb" />

Code in LogOut.aspx.vb
-----------------------------------------
Dim queryString As String
Dim data As New DataSet
Dim dbConnection As OleDbConnection
Dim dataAdapter As OleDbDataAdapter
Dim connectionString As String =
ConfigurationSettings.AppSettings("ConnectionStrin g")
queryString = "SELECT * FROM tblApplicLog"
dbConnection = New OleDbConnection(connectionString)
dataAdapter = New OleDbDataAdapter(queryString, dbConnection)
dataAdapter.Fill(data, "tblApplicLog")
Dim table As DataTable
table = data.Tables("tblApplicLog")
Dim selectedRows() As DataRow
Dim i As Integer = Application("iLastVisitTot")
selectedRows = table.Select("AplTotVisits = " & i)
If selectedRows.Length > 0 Then
selectedRows(0).Item("AplTotVisits") = Application("iVisitTot")
+ 1
End If

Dim commandBuilder As OleDbCommandBuilder
commandBuilder = New OleDbCommandBuilder(dataAdapter)
dataAdapter.UpdateCommand = commandBuilder.GetUpdateCommand
dataAdapter.Update(data, "tblApplicLog")
dbConnection.Close()

Server Error in '/Resume2' 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 214: commandBuilder = New OleDbCommandBuilder(dataAdapter)
Line 215: dataAdapter.UpdateCommand = commandBuilder.GetUpdateCommand
Line 216: dataAdapter.Update(data, "tblApplicLog")
Line 217: dbConnection.Close()
Line 218:
Source File: c:\inetpub\wwwroot\Resume2\LogOut.aspx.vb Line: 216

Stack Trace:
[OleDbException (0x80004005): Operation must use an updateable query.]
System.Data.Common.DbDataAdapter.Update(DataRow[] dataRows,
DataTableMapping tableMapping)
System.Data.Common.DbDataAdapter.Update(DataSet dataSet, String srcTable)
Resume2.LogOut.lbtClose_Click(Object sender, EventArgs e) in
c:\inetpub\wwwroot\Resume2\LogOut.aspx.vb:216
System.Web.UI.WebControls.LinkButton.OnClick(Event Args e)

System.Web.UI.WebControls.LinkButton.System.Web.UI .IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler
sourceControl, String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData)
System.Web.UI.Page.ProcessRequestMain()
Please help – Henry

Jul 21 '05 #1
2 4114
hch,

Although this one is not needed, is my question what data is there in
"data"?
(In other words how did you fill or save that during the post and postback?)
dataAdapter.UpdateCommand = commandBuilder.GetUpdateCommand


This one is not needed the command is already there because of the way you
do it.

Cor
Jul 21 '05 #2
The typical problmes are that 1) You don't have a Primary Key on the table
(not likely based on the current symptoms) 2) You don't have write
permissions (most likely). Verify that you can modify items in the db and
that you have write permissions, in an ASP.NET app, 98% of the time this
symptom is the result of permissions.

--
W.G. Ryan, MVP

www.tibasolutions.com | www.devbuzz.com | www.knowdotnet.com
"hch" <hc*@discussions.microsoft.com> wrote in message
news:2B**********************************@microsof t.com...

dataAdapter.Update(data, "TableName") won't work!
I was about to deploy my first website on the Internet only to discover
that
the dataAdapter.Update() throws the Server Error in the third underline.
It
was working fine before.
ConnectionString in Web.config:
-----------------------------------------
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="ConnectionString" value="Provider=Microsoft.Jet.OLEDB.4.0;Ole DB
Services=-4;Data Source=C:\databases\Resume1.mdb" />

Code in LogOut.aspx.vb
-----------------------------------------
Dim queryString As String
Dim data As New DataSet
Dim dbConnection As OleDbConnection
Dim dataAdapter As OleDbDataAdapter
Dim connectionString As String =
ConfigurationSettings.AppSettings("ConnectionStrin g")
queryString = "SELECT * FROM tblApplicLog"
dbConnection = New OleDbConnection(connectionString)
dataAdapter = New OleDbDataAdapter(queryString, dbConnection)
dataAdapter.Fill(data, "tblApplicLog")
Dim table As DataTable
table = data.Tables("tblApplicLog")
Dim selectedRows() As DataRow
Dim i As Integer = Application("iLastVisitTot")
selectedRows = table.Select("AplTotVisits = " & i)
If selectedRows.Length > 0 Then
selectedRows(0).Item("AplTotVisits") = Application("iVisitTot")
+ 1
End If

Dim commandBuilder As OleDbCommandBuilder
commandBuilder = New OleDbCommandBuilder(dataAdapter)
dataAdapter.UpdateCommand = commandBuilder.GetUpdateCommand
dataAdapter.Update(data, "tblApplicLog")
dbConnection.Close()

Server Error in '/Resume2' 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 214: commandBuilder = New OleDbCommandBuilder(dataAdapter)
Line 215: dataAdapter.UpdateCommand =
commandBuilder.GetUpdateCommand
Line 216: dataAdapter.Update(data, "tblApplicLog")
Line 217: dbConnection.Close()
Line 218:
Source File: c:\inetpub\wwwroot\Resume2\LogOut.aspx.vb Line: 216

Stack Trace:
[OleDbException (0x80004005): Operation must use an updateable query.]
System.Data.Common.DbDataAdapter.Update(DataRow[] dataRows,
DataTableMapping tableMapping)
System.Data.Common.DbDataAdapter.Update(DataSet dataSet, String
srcTable)
Resume2.LogOut.lbtClose_Click(Object sender, EventArgs e) in
c:\inetpub\wwwroot\Resume2\LogOut.aspx.vb:216
System.Web.UI.WebControls.LinkButton.OnClick(Event Args e)

System.Web.UI.WebControls.LinkButton.System.Web.UI .IPostBackEventHandler.RaisePostBackEvent(String
eventArgument)
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler
sourceControl, String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData)
System.Web.UI.Page.ProcessRequestMain()
Please help - Henry

Jul 21 '05 #3

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

Similar topics

6
by: Paul Eden | last post by:
Hello all. I'm totally stumped. Please de-stump me! I've read my data in from the database, changed it according to what i want to do and now I want to write it back. But it seems I can only...
7
by: | last post by:
I found similiar issues in MS-KB but nothing that helped me; got the Windows and Office updates from the MS website but that hasn't changed the behavior of this problem, and I don't see anything...
6
by: Jon Davis | last post by:
I like the drag-and-drop accessibility of dragging a table to a Web Forms designer and seeing a SqlDataAdapter automatically created for me.. being able to create a DataSet from that is fun and...
2
by: headware | last post by:
I'm relatively new to ASP.NET and ADO.NET, but I have a basic design question regarding the use of web services and APS.NET applications. Right now we have an application that uses web services to...
6
by: Geoff Pennington | last post by:
I have a class method that returns a DataAdapter. I want to access the table(s) contained in the DataAdapter. Of course, accessing the DataSets would be good enough, because I could get the tables...
4
by: hch | last post by:
dataAdapter.Update(data, "TableName") won’t work! I was about to deploy my first website on the Internet only to discover that the dataAdapter.Update() throws the Server Error in the third...
6
by: Marcel Hug | last post by:
Hi all ! I have a table in my database, which has 3 attributes. IDFailureControl, ControlDate and ControlVersion. In the following function I test, if the date of today allready exists. Then I...
1
by: MJR | last post by:
Could anyone please help me change data in uppercase to data in propercase in MS Access?
0
by: woollymammoth | last post by:
I can't assign a MS SQL Server table record value to a simple VB variable, should be an easy thing. Sample SQL Server table has the data in the record as a char(30) string, the column for that record...
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
2
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.