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