I was about to deploy my first website on the Internet (based on the Beginning ASP.NET 1.1) 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(Data Row[] dataRows, DataTableMapping tableMapping)
System.Data.Common.DbDataAdapter.Update(Data Set 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 (EventArgs e)
System.Web.UI.WebControls.LinkButton.System. Web.UI.IPostBackEventHandler.RaisePostBackEvent(St ring eventArgument)
System.Web.UI.Page.RaisePostBackEvent(IPostB ackEventHandler sourceControl, String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(NameVa lueCollection postData)
System.Web.UI.Page.ProcessRequestMain()
Please help â Henry