Wrox Programmer Forums
|
ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the 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 August 10th, 2004, 06:06 AM
Registered User
 
Join Date: Aug 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Updating Database

Hi..I'm simply trying to run the CommandExecute example in CH9 of ASP.NET 1.1 but anytime I run examples that need to update a database I get a "Operation must use an updateable query" error..
Any help appreciated.
Michael

 
Old August 10th, 2004, 07:06 AM
Friend of Wrox
 
Join Date: May 2004
Posts: 642
Thanks: 0
Thanked 43 Times in 42 Posts
Default

Can you paste the code?

Om Prakash
 
Old August 10th, 2004, 07:42 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,110
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Quote:
quote:Originally posted by om_prakash
 Can you paste the code?
Om Prakash
and can you tell us what database you are using?

 
Old August 10th, 2004, 09:13 AM
Registered User
 
Join Date: Aug 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thx for the prompt reply. CommandExecute.aspx is the code I'm using to try and update the Employees table in Northwind.mdb. I've got the code and database on a webserver.

Thx,
Michael


<%@ Page Language="VB" %>
<%@ Import Namespace="System.Data.OleDb" %>
<script runat="server">



    Sub btnRun_Click(sender As Object, e As EventArgs)
    Dim connectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0; " & _
        "Data Source=\\kgbrenna-desk\mtyoung\data\wind.mdb"
    Dim dbConnection As New OleDbConnection(connectionString)
    dbConnection.Open()

    Dim commandString As String = "INSERT INTO Employees(FirstName, LastName) " & _
        "Values(@FirstName, @LastName)"

    Dim dbCommand As New OleDbCommand(commandString, dbConnection)

    Dim firstNameParam As New OleDbParameter("@FirstName", OleDbType.VarChar, 10)
    firstNameParam.Value = txtFirstName.Text
    dbCommand.Parameters.Add(firstNameParam)

    Dim lastNameParam As New OleDbParameter("@LastName", OleDbType.VarChar, 20)
    LastNameParam.Value = txtLastName.Text
    dbCommand.Parameters.Add(LastNameParam)

    dbCommand.ExecuteNonQuery()

    dbConnection.Close()
    End Sub

</script>
<html>
<head>
</head>
<body>
    <form runat="server">
        <p>
            <asp:Label id="Label1" runat="server">First Name</asp:Label>
            <asp:TextBox id="txtFirstName" runat="server"></asp:TextBox>
        </p>
        <p>
            <asp:Label id="Label2" runat="server">Last Name</asp:Label>
            <asp:TextBox id="txtLastName" runat="server"></asp:TextBox>
        </p>
        <p>
            <asp:Button id="btnRun" onclick="btnRun_Click" runat="server" Text="Run"></asp:Button>
        </p>

    </form>
</body>
</html>






 
Old August 10th, 2004, 09:16 AM
Registered User
 
Join Date: Aug 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

P.S....I've actually changed the name of the database to wind.mdb in the code and on the server.

Thx.

 
Old August 12th, 2004, 10:13 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,101
Thanks: 0
Thanked 2 Times in 2 Posts
Default

What page of the book is this on?


Hal Levy
Web Developer, PDI Inc.

NOT a Wiley/Wrox Employee
 
Old August 12th, 2004, 10:15 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,110
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Check the folder that the database is in and make sure the ASPNET user account has write access.

 
Old August 12th, 2004, 07:13 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Hey,

Yes, I've seen that error many times because the ASPNET account doesn't have write access....

Brian





Similar Threads
Thread Thread Starter Forum Replies Last Post
updating database musicradiolive Classic ASP Databases 1 August 17th, 2006 12:23 AM
database not updating ellie BOOK: Beginning ASP 3.0 1 April 16th, 2006 05:28 AM
Help for Updating the database bspradeep Classic ASP Databases 1 May 10th, 2005 03:13 AM
Updating a database Gary_M Classic ASP Databases 4 November 7th, 2003 11:03 AM





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