473,396 Members | 2,021 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,396 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 4178
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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...

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.