Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > BOOK: Beginning ASP.NET 1.0
|
BOOK: Beginning ASP.NET 1.0
This is the forum to discuss the Wrox book Beginning ASP.NET 1.0 with C# by Chris Goode, John Kauffman, Christopher L. Miller, Neil Raybould, S. Srinivasa Sivakumar, Dave Sussman, Ollie Cornes, Rob Birdwell, Matt Butler, Gary Johnson, Ajoy Krishnamoorthy, Juan T. Llibre, Chris Ullman; ISBN: 9780764543708
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 1.0 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 May 4th, 2004, 09:41 AM
Registered User
 
Join Date: May 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chanpter13 Example (DirectSQL.aspx) Error--Please

Hi,

I tried to run this example DirectSql.aspx in Chapter 13, and I get the the following error.

 <%@ Page Language="C#" Debug="true" %>


<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>

<script Language="c#" runat="server">
  void Page_Load(object sender, EventArgs e)
  {
    OleDbConnection objConnection = null;
    OleDbCommand objCmd = null;

    string strConnection, strSQL;
    strConnection = "Provider=Microsoft.Jet.OleDb.4.0;";
    strConnection += @"Data Source=C:\BegASPNET\Northwind.mdb";

    // Create and open the connection object

    objConnection = new OleDbConnection(strConnection);
    objConnection.Open();

    // Set the SQL string
    strSQL = "INSERT INTO Employees ( FirstName , LastName ) VALUES ('Beth' , 'Hart' )";

    // Create the Command and set its properties

    objCmd = new OleDbCommand(strSQL, objConnection);

    // Execute the command

    objCmd.ExecuteNonQuery();
    lblStatus.Text = "Command run";
  }
</script>

<html>
  <body>
    <h2>Using SQL directly</h2>
    <asp:Label id="lblStatus" runat="server"/>
  </body>
</html>


---------------------------------------------------------------------




Server Error in '/BegASPNET' 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 30: // Execute the command
Line 31:
Line 32: objCmd.ExecuteNonQuery();
Line 33: lblStatus.Text = "Command run";
Line 34: }


Source File: c:\BegASPNET\directsql.aspx Line: 32

Stack Trace:


[OleDbException (0x80004005): Operation must use an updateable query.]
   System.Data.OleDb.OleDbCommand.ExecuteCommandTextE rrorHandling(Int32 hr) +41
   System.Data.OleDb.OleDbCommand.ExecuteCommandTextF orSingleResult(tagDBPARAMS dbParams, Object& executeResult) +154
   System.Data.OleDb.OleDbCommand.ExecuteCommandText( Object& executeResult) +92
   System.Data.OleDb.OleDbCommand.ExecuteCommand(Comm andBehavior behavior, Object& executeResult) +65
   System.Data.OleDb.OleDbCommand.ExecuteReaderIntern al(CommandBehavior behavior, String method) +112
   System.Data.OleDb.OleDbCommand.ExecuteNonQuery() +54
   ASP.directsql_aspx.Page_Load(Object sender, EventArgs e) in c:\BegASPNET\directsql.aspx:32
   System.Web.UI.Control.OnLoad(EventArgs e) +67
   System.Web.UI.Control.LoadRecursive() +29
   System.Web.UI.Page.ProcessRequestMain() +724




--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.0.3705.0; ASP.NET Version:1.0.3705.0





Rasanj
 
Old May 5th, 2004, 08:47 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Hello,

Does the ASPNET account have access to the database or to the folder?

Brian
 
Old May 6th, 2004, 09:35 AM
Registered User
 
Join Date: May 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Brain,

 Thanks for replying. Both the database and aspx are in the same folder. And I don't get any error message saying cannot connect to the database etc.



Rasanj
 
Old May 6th, 2004, 09:44 AM
Registered User
 
Join Date: May 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

  I checked the ASPNET account , it has read , write and execute permission.




Rasanj
 
Old May 6th, 2004, 09:54 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Hello,

Typically I've seen that type of error associated with the ASP.NET account not having permissions, because by default it would have read, which you would still be able to connect. Are you allowing anonymous access? If so, the account specified for that would need access too, I believe.

Also, maybe try adding "Mode=Share Deny None" to the connection string, I don't know if that will help?

Brian
 
Old May 7th, 2004, 10:05 AM
Registered User
 
Join Date: May 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

 Yes, Iam using anonymous access and I have access for this account.

Rasanj
 
Old May 7th, 2004, 06:56 PM
Registered User
 
Join Date: May 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

It's working fine now. The account MachineName\users account didn't have write permission, once I changed this my Insert started working fine. Can anybody explain this to me. Why anonymous access permission didn't work? and why MachineName\users
account should have write permission?

Thanks


Rasanj
 
Old May 8th, 2004, 04:37 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

If MachineName\Users seems to do the trick, then your setup is using an account that needed permissions, but didn't have them before. Since every account will be in the group Users, that particular account got the necessary permissions through its group membership of the group Users.

So apparently, you're using another account to run your site. To find out who that is, check the Directory Security tab in IIS. Check if Anonymous Access is enabled. If it is enabled, check the account that is used for this Web site.
Also, check out your Web.Config file. By default, when using Anonymous Access, ASP.NET will run under the special ASPNET account. However, if you enable impersonation, ASP.NET will run under a different account. With anonymous access, that account will be the good ol' IUSR_MachineName account; otherwise it could be you or some other user account.

If you post the relevant information here, we might be able to determine why the ASPNET account didn't work, while \Users did work....

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
While typing this post, I was listening to: Teenage Angst by Placebo (Track 2 from the album: Placebo) What's This?
 
Old June 15th, 2004, 11:39 AM
Registered User
 
Join Date: Jun 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I am having the same trouble with my server it is a windows 2003 server and i have added the IUSR_MACHINENAME and the ASPNET they both have full access permissions. but still getting the error i think my sql statment is fine but here it is INSERT INTO 'Users'('Name') VALUES ('bob') not sure what is wrong if i have some thing setup wrong on the server any help would be great thanks
 
Old June 15th, 2004, 12:51 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

For Windows 2003, take a look at the Network Service account. On 2003, that is the default account used for ASP.NET, not the ASPNET account.

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.





Similar Threads
Thread Thread Starter Forum Replies Last Post
error in default.aspx anass BOOK: ASP.NET Website Programming Problem-Design-Solution 1 June 24th, 2005 09:02 PM
roles.aspx error groupmatch BOOK: ASP.NET Website Programming Problem-Design-Solution 4 September 13th, 2004 02:39 PM
aspx error message... haghill ASP.NET 1.0 and 1.1 Basics 3 July 22nd, 2003 10:32 PM





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