Oracle 11G and SqlDataSource: The ugly 'ORA-01036: illegal variable name/number' Issue

Update: Fixed as described here: http://weblogs.asp.net/kencox/archive/2008/02/25/fixed-oracle-11g-and-sqldatasource-the-ugly-ora-01036-illegal-variable-name-number-issue.aspx 

 ----

I've created a short video to explain my problem with Oracle and SqlDataSource. If you'd rather watch than read, go see the video.

I'm trying to do some extremely simple drag and drop development in Visual Web Developer 2008 with the Oracle 11g database and ODP.NET. According to Oracle, "The data provider can be used with the latest .NET Framework 3.5 version. "

The SELECT statement works fine, but any attempt to use UPDATE via the SQLDataSource UpdateCommand nets me the infamous 'ORA-01036: illegal variable name/number'  error.

I wouldn't mind using one of my MSDN Support Incidents to have Microsoft take a look at this issue, but I'm not sure the problem is Microsoft's. It seems like Oracle is doing a poor job in its Visual Studio integration.

Question: Has anyone successfully used an UpdateCommand statement in SQLDataSource against Oracle 11g? If so, let me know!

Below, you see the entire code as generated in Visual Web Developer 2008. To see it in action, check the video.

Ken

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

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

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    
        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
            DataSourceID="SqlDataSource1" 
            EmptyDataText="There are no data records to display.">
            <Columns>
                <asp:CommandField ShowEditButton="True" />
                <asp:BoundField DataField="ACCOUNTID" HeaderText="ACCOUNTID" 
                    SortExpression="ACCOUNTID" />
                <asp:BoundField DataField="ACCOUNTNAME" HeaderText="ACCOUNTNAME" 
                    SortExpression="ACCOUNTNAME" />
                <asp:BoundField DataField="ACCOUNTLOCATION" HeaderText="ACCOUNTLOCATION" 
                    SortExpression="ACCOUNTLOCATION" />
                <asp:BoundField DataField="ACCOUNTPHONE" HeaderText="ACCOUNTPHONE" 
                    SortExpression="ACCOUNTPHONE" />
                <asp:BoundField DataField="ACCOUNTCONTACT" HeaderText="ACCOUNTCONTACT" 
                    SortExpression="ACCOUNTCONTACT" />
                <asp:BoundField DataField="ACCOUNTWEBSITE" HeaderText="ACCOUNTWEBSITE" 
                    SortExpression="ACCOUNTWEBSITE" />
            </Columns>
        </asp:GridView>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
            ConnectionString="<%$ ConnectionStrings:ConnectionString1 %>" 
            ProviderName="<%$ ConnectionStrings:ConnectionString1.ProviderName %>" 
            SelectCommand="SELECT &quot;ACCOUNTID&quot;, &quot;ACCOUNTNAME&quot;, &quot;ACCOUNTLOCATION&quot;, &quot;ACCOUNTPHONE&quot;, &quot;ACCOUNTCONTACT&quot;, &quot;ACCOUNTWEBSITE&quot; FROM &quot;ACCOUNTS&quot;" 
            UpdateCommand="UPDATE ACCOUNTS SET ACCOUNTLOCATION = 'This Place' WHERE (ACCOUNTID = 4)">
        </asp:SqlDataSource>
    
    </div>
    </form>
</body>
</html>
//////////
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
}
Published 24 February 2008 12:06 PM by Ken Cox [MVP]

Comments

# Oracle 11G and SqlDataSource: The ugly 'ORA-01036: illegal variable name/number' Issue - WebLog of Ken Cox said on 24 February, 2008 03:47 PM

Pingback from  Oracle 11G and SqlDataSource: The ugly 'ORA-01036: illegal variable name/number' Issue - WebLog of Ken Cox

# DotNetKicks.com said on 25 February, 2008 07:59 AM

You've been kicked (a good thing) - Trackback from DotNetKicks.com

# Mark Wisecarver said on 25 February, 2008 08:00 AM

Thanks Ken.

I migrated an Oracle world to SQL Server for Siemens and am still recovering from that experience. ;-)

# Mebeti Dosso said on 14 March, 2008 04:41 PM

I am using oracle 11g and I wrote this sample code to test the update with sqldatasource. It works successfully. I have the following i addition to your settings:

1. <UpdateParameters>

2. UpdateCommandType="Text"

3. ConflictDetection="OverwriteChanges"

Below is my code. No code behind

<asp:GridView ID="GridView1" AllowSorting="true" AllowPaging="true" Runat="server" Width="400px"

       DataSourceID="SqlDataSource1" AutoGenerateEditButton="true" DataKeyNames="request_id"

       AutoGenerateColumns="False">

       <Columns>

         <asp:BoundField ReadOnly="true" HeaderText="ID" DataField="request_id" SortExpression="request_id" />

         <asp:BoundField HeaderText="Description" DataField="Description" SortExpression="Description" />          

       </Columns>

     </asp:GridView>

     <asp:SqlDataSource ID="SqlDataSource1" Runat="server" SelectCommand="SELECT request_id, Description FROM picklist_request"

       ConflictDetection="OverwriteChanges" UpdateCommandType="Text" SelectCommandType="text"

       UpdateCommand="UPDATE picklist_request SET Description = :Description WHERE request_id = :Request_ID"

       ConnectionString="<%$ ConnectionStrings:LibraryConnectionMS %>" ProviderName="<%$ ConnectionStrings:LibraryConnectionMS.ProviderName %>">

       <UpdateParameters>

           <asp:Parameter Name="Description"  Type="String" />

           <asp:Parameter Name="Request_ID" Type="int32" />

       </UpdateParameters>    

    </asp:SqlDataSource>

# vesile.taskiran@ttgint.com said on 02 May, 2008 09:07 AM

i have exactly the same problem.Could you find the solution?

regards

# xyz said on 09 May, 2008 07:17 PM

1- Dont use SqlDataSource

Dont use OracleProvider

if you use OracleProvider

"I would recommend using Oracle Developer Tools (ODT) for VS and ODP.NET since these products are much better integrated with .NET and Oracle.   ODP.NET uses Oracle.DataAccess.Client namespace. System.Data.OracleClient belongs to the MS provider for Oracle, which Mark pointed out. If you drag and drop DB objects using ODT, it will generate ODP.NET code for you (and give you more data source wizard options as well).

  - You can download the latest 11g version of ODP.NET and ODT here:   www.oracle.com/.../index.html

2- Dont use vizard for bindings and if it is possible use DataGrid like , I think if it is usefull below:

           <asp:UpdatePanel runat="server" ID="UpdatePanel2">

               <ContentTemplate>

                   <table width="600">

                       <tr>

                           <td valign="middle">

                               Seri No</td>

                           <td>

                               :</td>

                           <td valign="middle">

                               <asp:TextBox ID="txtSeriNo" runat="server" CssClass="TextBox"></asp:TextBox><asp:Button ID="Insertt" Text="Insertt"

                                   runat="server" OnClick="Insertt_Click" CausesValidation="False" CssClass="Buton" />

                               <asp:Label ID="lblError" runat="server" Font-Names="Verdana" Font-Size="X-Small"></asp:Label></td>

                       </tr>

                       <tr>

                           <td colspan="3" align="left" style="font-family: Verdana; font-size: small;">

                               <asp:DataGrid ID="grdDataGrid" Font-Size="X-Small" runat="server" AllowPaging="false"

                                   AllowSorting="false" AutoGenerateColumns="False" CellPadding="2" CellSpacing="0"

                                   ForeColor="#333333" GridLines="Vertical" Width="539px" OnItemCommand="grdDataGrid_ItemCommand"

                                   BorderStyle="Solid" BorderWidth="1px" OnSelectedIndexChanged="grdDataGrid_SelectedIndexChanged">

                                   <FooterStyle BackColor="#507CD1" Font-Bold="False" ForeColor="White" />

                                   <EditItemStyle BackColor="#2461BF" />

                                   <SelectedItemStyle BackColor="#D1DDF1" Font-Bold="False" ForeColor="#333333" />

                                   <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />

                                   <AlternatingItemStyle BackColor="White" Font-Size="X-Small" />

                                   <ItemStyle BackColor="#EFF3FB" Font-Size="X-Small" />

                                   <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" Font-Size="X-Small" />

                                   <Columns>

                                       <asp:BoundColumn DataField="SERIAL_NO" HeaderText="Seri No"></asp:BoundColumn>

                                       <asp:BoundColumn DataField="DEVICE" HeaderText="Device"></asp:BoundColumn>

                                       <asp:BoundColumn DataField="MODEL" HeaderText="Type"></asp:BoundColumn>

                                       <asp:TemplateColumn>

                                           <ItemTemplate>

                                               <asp:LinkButton ID="LinkButton1" runat="server" CommandName="Dell" Text="Dell" CausesValidation="false"></asp:LinkButton>

                                           </ItemTemplate>

                                       </asp:TemplateColumn>

                                   </Columns>

                               </asp:DataGrid>

                           </td>

                       </tr>

                   </table>

               </ContentTemplate>

           </asp:UpdatePanel>

And in the Code behind Section java script or C# codes

like (allways you think) below:

   protected void grdDataGrid_ItemCommand(object source, DataGridCommandEventArgs e)

   {

       tbProduct = (DataTable)Session["Product"];

       tbProduct.Rows.RemoveAt(e.Item.ItemIndex);

       grdDataGrid.DataSource = tbProduct;

       grdDataGrid.DataBind();

       Session["Product"] = tbProduct;

   }

# Rupesh Kumar said on 30 October, 2008 12:37 AM

I have the same problem of getting an exception ORA 01036 illegal variable name/number and i am using oracle 8i, updation works fine if I give the update command and select command in the "DESIGN MODE" but it gives above mentioned exception when i code the command in the code behind page. Can anybody help?

# Adel said on 09 November, 2008 06:31 AM

Hi guys,

just do the following

change the sqldatasourse property from ConflictDetection="CompareAllValues"  to  ConflictDetection="OverwriteChanges

good luck

# wrociu said on 18 March, 2009 07:48 PM

I had similar problem today ...

I was trying to make a simple code to see how connection to Oracle works ...

this is how my code looked like :

OracleCommand insCom = new OracleCommand("INSERT INTO pomoctechniczna VALUES(1,1,:Cat,:Sub,"

               + ":Opis,1)" , DataBaseCon);

           insCom.Parameters.Add(":Cat", OracleType.Number,11);

           insCom.Parameters[":Cat"].Value = Convert.ToDecimal(categoryList.SelectedItem.Value);

           insCom.Parameters.Add(":Sub", OracleType.Number, 11);

           insCom.Parameters[":Sub"].Value = Convert.ToDecimal(subjectList.SelectedItem.Value);

           insCom.Parameters.Add(":Opis", OracleType.VarChar, 50);

           insCom.Parameters[":Opis"].Value = descriptionTextBox.Text;

I had this "ORA-01036: illegal variable name/number "

and this is how it looks like now :

OracleCommand insCom = new OracleCommand("BEGIN INSERT INTO pomoctechniczna VALUES(1,1,:Cat,:Sub,"

               + ":Opis,1); END;" , DataBaseCon);

And now it works ... Anonymous block must be used ( BEGIN ... END ) ... the prefix really doesn't matter :)

Leave a Comment

(required) 
(required) 
(optional)
(required) 

Search

Go

This Blog

Web Links

Syndication