Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > BOOK: Beginning ASP.NET 1.1
|
BOOK: Beginning ASP.NET 1.1
This is the forum to discuss the Wrox book Beginning ASP.NET 1.1 with Visual C#.NET 2003 by Chris Ullman, John Kauffman, Chris Hart, Dave Sussman, Daniel Maharry; ISBN: 9780764557088
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 1.1 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 28th, 2005, 03:50 PM
Registered User
 
Join Date: Aug 2005
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chapter 11: Operation must use an updateable query

I'm trying to follow the cookie coding example in chapter 11. I'm getting the following error when trying to write an email address to the mdb, at this step of the code:

rowsAffected = dbCommand.ExecuteNonQuery

The code was generated by WebMatrix except I modified the connection string per the instructions.

Thanks in advance.

Kevin

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 193: dbConnection.Open
Line 194: Try
Line 195: rowsAffected = dbCommand.ExecuteNonQuery
Line 196: Finally
Line 197: dbConnection.Close

This is my code:

Function AddNewFanEmail(ByVal fanEmail As String) As Integer

Dim connectionString As String = ConfigurationSettings.AppSettings("ConnectionStrin g")
Dim dbConnection As System.Data.IDbConnection = New System.Data.OleDb.OleDbConnection(connectionString )

Dim queryString As String = "INSERT INTO [Fans] ([FanEmail]) VALUES (@FanEmail)"
Dim dbCommand As System.Data.IDbCommand = New System.Data.OleDb.OleDbCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection

Dim dbParam_fanEmail As System.Data.IDataParameter = New System.Data.OleDb.OleDbParameter
dbParam_fanEmail.ParameterName = "@FanEmail"
dbParam_fanEmail.Value = fanEmail
dbParam_fanEmail.DbType = System.Data.DbType.String
dbCommand.Parameters.Add(dbParam_fanEmail)

Dim rowsAffected As Integer = 0
dbConnection.Open
Try
     rowsAffected = dbCommand.ExecuteNonQuery
Finally
     dbConnection.Close
End Try

Return rowsAffected

End Function


 
Old September 30th, 2005, 04:18 PM
Registered User
 
Join Date: Aug 2005
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

FYI: Here is my connection string.
Dim connectionString As String = ConfigurationSettings.AppSettings("ConnectionStrin g")

<appSettings>
<add key="connectionstring" value="Provider=Microsoft.Jet.OLEDB.4.0; Ole DB Services=-4; Data Source=C:\Begining ASP.NET 1.1\Data\WroxUnited.mdb"/>
</appSettings>

At any rate, I modified the code to use the SQL database and it works fine. It's almost like the .mdb file has an issue.

For reference, here is my code turned set to use the SQL database.

If anyone else has had a weird experience with the mdb I'd like to know you
you got around it.

Thanks.

Kevin


    Function AddNewFanEmail(ByVal fanEmail As String) As Integer

        Dim connectionString As String = ConfigurationSettings.AppSettings("ConnectionStrin g")
        'Dim dbConnection As System.Data.IDbConnection = New System.Data.OleDb.OleDbConnection(connectionString )
        Dim dbConnection As System.Data.IDbConnection = New System.Data.SqlClient.SqlConnection(connectionStri ng)


       Dim queryString As String = "INSERT INTO [Fans] ([FanEmail]) VALUES (@FanEmail)"


        'Dim dbCommand As System.Data.IDbCommand = New System.Data.OleDb.OleDbCommand
        Dim dbCommand As System.Data.IDbCommand = New System.Data.SqlClient.SqlCommand
        dbCommand.CommandText = queryString
        dbCommand.Connection = dbConnection

        'Dim dbParam_fanEmail As System.Data.IDataParameter = New System.Data.OleDb.OleDbParameter
        Dim dbParam_fanEmail As System.Data.IDataParameter = New System.Data.SqlClient.SqlParameter
        dbParam_fanEmail.ParameterName = "@FanEmail"
        dbParam_fanEmail.Value = fanEmail
        dbParam_fanEmail.DbType = System.Data.DbType.String
        dbCommand.Parameters.Add(dbParam_fanEmail)



        Dim rowsAffected As Integer = 0
        dbConnection.Open
        Try
            rowsAffected = dbCommand.ExecuteNonQuery
        Finally
            dbConnection.Close
        End Try

        Return rowsAffected

    End Function


 
Old September 30th, 2005, 05:27 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Most likely, this is a security error. Check this FAQ for the solution:

http://imar.spaanjaars.com/QuickDocId.aspx?QUICKDOC=263

You may also need this faq to determine your IIS account:

http://imar.spaanjaars.com/QuickDocId.aspx?QUICKDOC=287

HtH,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
While typing this post, I was listening to: Stay by Tricky (Track 1 from the album: Vulnerable) What's This?
 
Old October 4th, 2005, 03:07 PM
Registered User
 
Join Date: Aug 2005
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you Imar. These articles are excellent!

Kevin






Similar Threads
Thread Thread Starter Forum Replies Last Post
Operation must use an updateable query darkhalf Access 4 February 29th, 2008 12:50 PM
Operation must use an updateable query hchlebowski ASP.NET 1.0 and 1.1 Basics 1 January 24th, 2006 07:11 AM
Operation must use an updateable query. Laindir Sarnon Classic ASP Databases 6 September 2nd, 2004 04:27 PM
Operation must use an updateable query chaos2003 Classic ASP Databases 4 August 22nd, 2003 03:04 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.