Results 1 to 3 of 3

Thread: Error: Operation must use an updateable query.

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Sep 2003
    Location
    BH
    Posts
    22

    Unhappy Error: Operation must use an updateable query.

    Hi everybody

    I can tell that there we people who faced this problem before, please help if you know any solution..

    when I try to add a record to the (Access) database using OledbCommand in Asp.net, it gives me the error: (Operation must use an updateable query. ).. but if i try the same code in Windows-based application it works fine... amazingly, it works too if using WebMatrix..

    Do u have any clue..
    the code I'm trying is
    Code:
    <%@ import Namespace="System.Data.Oledb" %>
    <%@ import Namespace="System.Data" %>
    <%@ Page Language="VB" %>
    <HTML>
    	<HEAD>
    		<title>Reading from a database</title>
    		<script runat="server">
    
        Dim con As OleDbConnection = New OleDbConnection
        Dim comm As OleDbCommand = New OleDbCommand
        
        ' This subroutine is called when the page is loaded
               Sub Page_Load (Sender As Object, E As EventArgs)
                       LoadGrid()
        End Sub
        
               ' This subroutine is used to populate the datagrid
               Sub LoadGrid()
                   Dim adaptor As OleDbDataAdapter = New OleDbDataAdapter
                Dim patientDS As DataSet = New DataSet
        
                   con.ConnectionString = _
                       "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=db.mdb"
            comm.CommandText = "Select * From Patient"
            comm.Connection = con
            adaptor.SelectCommand = comm
            adaptor.SelectCommand.Connection.Open
            adaptor.Fill(patientDS, "Patient")
            PatientTable.DataSource = patientDS.Tables("Patient")
            PatientTable.DataBind
                       con.close()
               End Sub
        
               'This subroutine is called when a button is clicked
        Sub cmdSubmit_Click (sender As Object, e As EventArgs)
            Dim SQLtext as String
            SQLText = "('" & txtFirst.Text & "','" & _
                                          txtMiddle.Text & "'," & _
                      txtCPR.Text & ", '" & _
                                           Gender.selectedItem.Value & "',#" & _
                      txtDOB.Text  & "#)"
                       
                       
                       con.Open()
    			comm.CommandText = "INSERT INTO Patient VALUES " & _
                                                           SQLText
            comm.Connection = con
            comm.ExecuteNonQuery()
            con.close()
                       ClearControls()
                       LoadGrid()
        End Sub
        
               'This subroutine is used to clear the text fields
               Sub ClearControls()
                       txtFirst.Text = ""
                       txtMiddle.Text = ""
                       txtCPR.Text = ""
                       txtDOB.Text = ""
               End Sub
    
    		</script>
    	</HEAD>
    	<body>
    		<h1>Patient Database
    		</h1>
    		<form runat="server" ID="Form1">
    			<p>
    				<asp:datagrid id="PatientTable" runat="server" border="5"></asp:datagrid>
    			</p>
    			<br>
    			<br>
    			<p>
    				Patient Name: First:
    				<asp:TextBox id="txtFirst" runat="server"></asp:TextBox>
    				&nbsp; Middle:
    				<asp:TextBox id="txtMiddle" runat="server"></asp:TextBox>
    			</p>
    			<p>
    				Patient Data: CPR:
    				<asp:TextBox id="txtCPR" runat="server"></asp:TextBox>
    				&nbsp;Date Of Birth:
    				<asp:TextBox id="txtDOB" runat="server"></asp:TextBox>
    			</p>
    			<p>
    				Gender
    				<asp:RadioButtonList id="Gender" runat="server">
    					<asp:listitem id="optMale" runat="server" value="Male" />
    					<asp:listitem id="optFemale" runat="server" value="Female" />
    				</asp:RadioButtonList>
    			</p>
    			<asp:Button id="cmdSubmit" onclick="cmdSubmit_Click" runat="server" Text="Add Record"></asp:Button>
    		</form>
    	</body>
    </HTML>
    This code works fine in WebMatrix.. but gives the error in Visual Studio .net..... please help
    I'ts not so much where you stand in life, but in what direction you are moving

  2. #2
    Addicted Member Rockhopper's Avatar
    Join Date
    Aug 2003
    Location
    Cape Town, South Africa
    Posts
    199

    Re: Error: Operation must use an updateable query.

    lol, you say that your code works in a windows app.

    Well, i had this error when starting to use Access in ASP.
    Turn on your guest account (or at leat give your ASP.Net user account rights to your ASP.Net Application's folder). The problem occurs because your ASPNet user account doesn't have rights to your web application folder.

    Let us know if this solves the problem.

    g'luck
    If the facts don't fit the theory, change the facts. --Albert Einstein

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Sep 2003
    Location
    BH
    Posts
    22

    Re: Error: Operation must use an updateable query.

    Quote Originally Posted by Rockhopper
    lol, you say that your code works in a windows app.

    Turn on your guest account (or at leat give your ASP.Net user account rights to your ASP.Net Application's folder). The problem occurs because your ASPNet user account doesn't have rights to your web application folder.

    Let us know if this solves the problem.

    g'luck
    Well thanks mate,
    I tried and turned the guest acount, but still have the same problem.
    I tried giving Asp.net Machine user account and administrative privilages,, but still have the problem...

    but how can i give my ASP.Net user account rights to your ASP.Net Application's folder?

    thank ya
    I'ts not so much where you stand in life, but in what direction you are moving

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width