 |
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
|
|
|
|
|

January 29th, 2004, 12:34 AM
|
|
Registered User
|
|
Join Date: Jan 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Chapter-13-direct SQL command-ExecuteNonQuery erro
Hi everyone,
I'm having a problem when I run the code DirectSQL.aspx in Chapter 13. I know that I have priveleges to update the database. I was able to update and insert to the database by using the old asp and ADO connection but no luck with the snippet in the book. The error I'm getting is the following:
Line 30: // Execute the command
Line 31:
Line 32: objCmd.ExecuteNonQuery();
Line 33: lblStatus.Text = "Command run";
Line 34: }
Source File: d:\inetpub\wwwroot\senior projects\eldamn\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) +174
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() +66
ASP.directsql_aspx.Page_Load(Object sender, EventArgs e) in d:\inetpub\wwwroot\senior projects\eldamn\directSQL.aspx:32
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Page.ProcessRequestMain() +731
Please help. I'm really stuck on this one.
Thanks so much for any feedback.
SoftDev
SoftDev
|
|

January 29th, 2004, 09:59 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
|
|
What's the rest of the code look like? I don't have the book.
|
|

January 29th, 2004, 11:38 AM
|
|
Registered User
|
|
Join Date: Jan 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Good to hear from you bmains :)
Here is the code:
<%@ 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=d:\inetpub\wwwroot\senior projects\eldamn\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>
SoftDev
|
|

January 29th, 2004, 12:21 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
|
|
|
|

January 29th, 2004, 09:54 PM
|
|
Registered User
|
|
Join Date: Jan 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thank you! I'm going to send this information to the administrator of the server I'm running my page on.
SoftDev
|
|

February 5th, 2004, 11:42 PM
|
|
Registered User
|
|
Join Date: Jan 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Still not working. I have read/write permissions on the directory where the database resides. The table I'm updating doesn't have dependent relationship with other tables. Please help. Thanks
SoftDev
|
|

February 22nd, 2004, 07:55 PM
|
|
Registered User
|
|
Join Date: Jan 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I got it.
It is privilege problem. All ASPX un under a special user account with the name of ASPNET. When I asked the administrator to grant this account (ASPNET) read/write/execute privileges, I was able to update the database with no problem.
SoftDev
|
|
 |