Skip to Main Content

ODP.NET

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Unable to update columns using a simple GridView

ianm42Jul 5 2006 — edited Jul 8 2006
I am trying to learn ASP.NET 2.0 by putting together a small website using ASP.NET 2.0, VB via Visual Web Developer 2005 Express, ODP.NET, IIS on Windows Server 2003, with an Oracle 10g Express Edition database.

I have had to modify some of code automatically generated by Visual Web Developer 2005 Express to make it work with Oracle, but I have now come to a problem I can't find a solution to.

I have a simple GridView based on a simple SQL Select on a single table. It displays the table contents successfully. I have added the standard Update ability. However, Update does not seem to work. All the bound variables appear to be NULL. I replaced the update SQL statement with a call to a PL/SQL procedure to log the values of the bound variables. The procedure gets called, but all the values are NULL.

Anyone got a clue what I am doing wrong?

Ian Morgan
Munich

Here is the code:
~~~~~~~~~~~~~
<%@ Page Language="VB"  Explicit="true" Debug="true" Title="Test - Order" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="Oracle.DataAccess.Client" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
        
    Sub Page_Load(ByVal Sender As Object, ByVal E As EventArgs)
        SqlDataSource1.ConnectionString = "Data Source=XE;" _
                                   + "User Id=scott;" _
                                   + "Password=tiger;"
    End Sub

</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">

</head>
<body>
    <form id="printorder" runat="server">
    <div>
    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="ORDER_ID"
        DataSourceID="SqlDataSource1" >
        <Columns>
            <asp:CommandField ShowEditButton="True" ShowSelectButton="True" />
            <asp:BoundField DataField="ORDER_ID" HeaderText="ORDER_ID" ReadOnly="True" SortExpression="ORDER_ID" />
            <asp:BoundField DataField="ORDER_NUMBER" HeaderText="ORDER_NUMBER" ReadOnly="True" SortExpression="ORDER_NUMBER" />
            <asp:BoundField DataField="REMARKS" HeaderText="REMARKS" SortExpression="REMARKS" />
            <asp:BoundField DataField="SPECIAL_INSTRUCTIONS" HeaderText="SPECIAL_INSTRUCTIONS"
                SortExpression="SPECIAL_INSTRUCTIONS" />
        </Columns>
    </asp:GridView>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="empty"
        ProviderName="<%$ ConnectionStrings:gfConnectionString.ProviderName %>" 
        SelectCommand='SELECT "ORDER_ID", "ORDER_NUMBER", "REMARKS", "SPECIAL_INSTRUCTIONS" FROM "GF_ORDERS" ORDER BY "ORDER_NUMBER" DESC'
        UpdateCommand='UPDATE "GF_ORDERS" SET "REMARKS" = :REMARKS, "SPECIAL_INSTRUCTIONS" = :SPECIAL_INSTRUCTIONS WHERE "ORDER_ID" = :ORDER_ID'>
        <UpdateParameters>
            <asp:Parameter Name="REMARKS" Type="String" />
            <asp:Parameter Name="SPECIAL_INSTRUCTIONS" Type="String" />
            <asp:Parameter Name="ORDER_ID" Type="Decimal" />
        </UpdateParameters>
    </asp:SqlDataSource>

    </div>
    </form>
</body>
</html>
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 5 2006
Added on Jul 5 2006
4 comments
927 views