(C#/2.0) ORA-01036 Error When Upd/Ins/Del from Gridview

  • Thread starter David R. Longnecker
  • Start date
D

David R. Longnecker

I'm migrating existing ASP 3.0 web applications to C#/2.0 and have run into
an error that has stumped me. The Gridview is designed to replace an
old-fashioned loop through a database that writes out textboxes of user
information for a "semi-user maintenance" screen. The gridview reads out of
an Oracle database (no problems there) and I'm manually adding the
INSERT/UPDATE/DELETE commands to my SqlDataSource; however, no matter what
format I try, the variables come back with:

--
ORA-01036: illegal variable name/number
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.Data.OracleClient.OracleException: ORA-01036:
illegal variable name/number
--

I researched the error and found similar posts with the error
(http://objectsharp.com/Blogs/bruce/archive/2004/09/17/883.aspx); however,
as you can see in my code below (unless I misunderstand), my variables are
far under the 32-character limit (unless it's a collective limit or
something). So far, the MSDN library/premier library hasn't turned up
anything for the Oracle error. The Oracle site gives me that the error
means: --Unable to find bind context on user side. Make sure that the
variable being bound is in the SQL statement.--
(http://forums.oracle.com/forums/thread.jspa?messageID=1130432); however,
that seems focused around 1.1 and not the new gridviews of 2.0.

My GirdView/SqlDataSource code:

--
<asp:GridView ID="staffTable" runat="server" AllowSorting="True"
AutoGenerateColumns="False"
CellPadding="4" DataSourceID="sqlStaffMaint" DataKeyNames="staff_id"
AllowPaging="True"
PageSize="100" AutoGenerateDeleteButton="true"
AutoGenerateEditButton="true">
<Columns>
<asp:BoundField DataField="STAFF_ID" Visible="False" />
<asp:BoundField DataField="AD_ID" HeaderText="User Name"
SortExpression="AD_ID" />
<asp:BoundField DataField="ESIS_ID" HeaderText="SSN"
SortExpression="ESIS_ID" />
<asp:BoundField DataField="SCHOOL_ID" HeaderText="School #"
SortExpression="SCHOOL_ID" />
<asp:BoundField DataField="ACCESS_ID" HeaderText="Access Level"
SortExpression="ACCESS_ID" />
</Columns>
</asp:GridView>

<asp:SqlDataSource ID="sqlStaffMaint" runat="server"
ConnectionString="<%$ ConnectionStrings:addStaffCS %>"
ProviderName="<%$ ConnectionStrings:addStaffCS.ProviderName %>"
SelectCommand="SELECT * FROM staff"
UpdateCommand="UPDATE staff SET ad_id=@ad_id, esis_id=@esis_id,
school_id=@school_id, access_id=@access_id WHERE staff_id=@staff_id"
DeleteCommand="DELETE FROM staff where staff_id=@staff_id"
InsertCommand="INSERT INTO staff (ad_id, esis_id, school_id,
access_id) VALUES (@ad_id, @esis_id, @school_id, @access_id)">
</asp:SqlDataSource>
--

My web.config connection string information:

--
<connectionStrings>
<add name="addStaffCS" connectionString="Data
Source=server.domain.com;Persist Security Info=True;User
ID=userName;Password=passWord"
providerName="System.Data.OracleClient" />
</connectionStrings>
--

The short (after all of that) seems to be: Can a gridview connect for all
operations (select, insert, update, delete) to an Oracle database? If so,
how do you get around this variable issue?

Thanks in advance!

-David

--

David R. Longnecker
CCNA, MCSA, Network+, A+
Management Information Services
Wichita Public Schools, USD 259
 
K

Kevin Yu [MSFT]

Hi David,

This seems to have something to do with the parameter naming convension.
For the OracleClient .NET Data Provider, use Oracle's parameter naming
convention where the parameter name (which includes a ":") appears in the
query rather than the OLE DB / ODBC parameter marker "?".

You can check the following link for more information

http://lab.msdn.microsoft.com/ProductFeedback/viewFeedback.aspx?feedbackid=2
9a302b1-81e4-44f9-8c9d-90cec3c93340

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
D

David R. Longnecker

Ahh! Works like a charm! Thanks!

-David

--

David R. Longnecker
CCNA, MCSA, Network+, A+
Management Information Services
Wichita Public Schools, USD 259
 
K

Kevin Yu [MSFT]

You're welcome.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
D

David R. Longnecker

Update:

Okay, works fine with numbers and "non-strings"... however, strings don't
error out; they just do not return any results.

Example:

SELECT report_id, pupil_id, teacher_id, start_date, year, quarter
FROM reports
WHERE teacher_id = (SELECT ssn FROM staff WHERE ad_id = :textbox)

I can switch it around and query on the ssn rather than the ad_id (select
ad_id from staff where ssn = :textbox), and it works just fine. I tried
':textbox', ":textbox", etc, with no avail.

Ideas?

Thanks!

-David
 
K

Kevin Yu [MSFT]

Hi David,

I think it was not updated because there isn't rows that matches the
criteria. You can try to change = to IN like the following:

SELECT report_id, pupil_id, teacher_id, start_date, year, quarter
FROM reports
WHERE teacher_id IN (SELECT ssn FROM staff WHERE ad_id = :textbox)

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
D

David R. Longnecker

Kevin-

Sorry for the long reply time--it was one of those weeks!

You suggested using IN rather than =; however, I still seem to have trouble
querying using any non-numerics. Using the query below and searching for
something like 'dlongnecker' fails.

SelectCommand="SELECT staff_id, ad_id, teacher_id, access_id FROM staff
where ad_id = :textbox"

However, changing it back to querying a numeric value and querying for my
teacher ID works just fine.

SelectCommand="SELECT staff_id, ad_id, teacher_id, access_id FROM staff
where teacher_id = :textbox"

I copied and pasted the query and replaced :textbox with the actual string
'VALUE' into SQLPlus and, again, it worked just fine. It seems like it's
forgetting to put the 'quotes' around the string values and, since Oracle
doesn't use quotes on numerics, leads to why they work.

Ideas?

Thanks in advance!

-David
 
K

Kevin Yu [MSFT]

Hi David,

Can you try to use some trace tool to see what is really executing on the
Oracle server and use SQL Plus to run it to see if there is anything wrong
with it?

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
D

David R. Longnecker

Kevin-

Unfortunately, I've never tried to trace one of these new GridView tools; so I'm not quite sure how to look into the SelectCommand property of it DURING the Oracle lookup. I did verify that it is what I anticipated using a Trace.Write.

page posted back; value entered for textbox: dlongnecker

select command: SELECT staff_id, AD_ID, ESIS_ID, SCHOOL_ID, ACCESS_ID FROM staff where AD_ID = :textbox

The full Trace log is below... how would I lookup the GridView in progress?

Thanks!

-David


Request Details
Session Id: llye4xj5f0aucdqifktacu45 Request Type: POST
Time of Request: 1/24/2006 10:43:35 AM Status Code: 200
Request Encoding: Unicode (UTF-8) Response Encoding: Unicode (UTF-8)
Trace Information
Category Message From First(s) From Last(s)
aspx.page Begin PreInit
aspx.page End PreInit 0.000236143179350096 0.000236
aspx.page Begin Init 0.000272799264890151 0.000037
aspx.page End Init 0.000328832177762927 0.000056
aspx.page Begin InitComplete 0.000356170745969426 0.000027
aspx.page End InitComplete 0.0003836697017793 0.000027
aspx.page Begin LoadState 0.000409599866343664 0.000026
aspx.page End LoadState 0.000650203825912622 0.000241
aspx.page Begin ProcessPostData 0.000684787402890318 0.000035
aspx.page End ProcessPostData 0.000841298137164815 0.000157
aspx.page Begin PreLoad 0.000872310583911119 0.000031
aspx.page End PreLoad 0.00090773368975023 0.000035
aspx.page Begin Load 0.000935931835268566 0.000028
longnecker page posted back; value entered for textbox: dlongnecker 0.000966147356110601 0.000030
longnecker select command: SELECT staff_id, AD_ID, ESIS_ID, SCHOOL_ID, ACCESS_ID FROM staff where AD_ID = :textbox 0.000993703951215437 0.000028
aspx.page End Load 0.00103390360036756 0.000040
aspx.page Begin ProcessPostData Second Try 0.0010628485506641 0.000029
aspx.page End ProcessPostData Second Try 0.00109956227549912 0.000037
aspx.page Begin Raise ChangedEvents 0.00112819647481413 0.000029
aspx.page End Raise ChangedEvents 0.0011578882298889 0.000030
aspx.page Begin Raise PostBackEvent 0.00118580319104503 0.000028
aspx.page End Raise PostBackEvent 0.00121508645894244 0.000029
aspx.page Begin LoadComplete 0.00124175089800351 0.000027
aspx.page End LoadComplete 0.0013307384512572 0.000089
aspx.page Begin PreRender 0.00136315428953304 0.000032
aspx.page End PreRender 0.00764205580152034 0.006279
aspx.page Begin PreRenderComplete 0.00769756745468215 0.000056
aspx.page End PreRenderComplete 0.0077281689081948 0.000031
aspx.page Begin SaveState 0.0088755041349929 0.001147
aspx.page End SaveState 0.00912354356361206 0.000248
aspx.page Begin SaveStateComplete 0.00915645810709214 0.000033
aspx.page End SaveStateComplete 0.00918538802105087 0.000029
aspx.page Begin Render 0.00921945535043021 0.000034
aspx.page End Render 0.0109023222788405 0.001683
Control Tree
Control UniqueID Type Render Size Bytes (including children) ViewState Size Bytes (excluding children) ControlState Size Bytes (excluding children)
__Page ASP.staffmaint_aspx 15118 0 0
ctl00 ASP.masterpage_master 15118 0 0
ctl00$ctl03 System.Web.UI.LiteralControl 177 0 0
ctl00$ctl00 System.Web.UI.HtmlControls.HtmlHead 616 0 0
ctl00$ctl01 System.Web.UI.HtmlControls.HtmlTitle 33 0 0
ctl00$ctl02 System.Web.UI.HtmlControls.HtmlLink 63 0 0
ctl00$ctl04 System.Web.UI.LiteralControl 176 0 0
aspnetForm System.Web.UI.HtmlControls.HtmlForm 14129 0 0
ctl00$ctl05 System.Web.UI.ResourceBasedLiteralControl 798 0 0
ctl00$TreeView1 System.Web.UI.WebControls.TreeView 6873 1308 0
ctl00$ctl06 System.Web.UI.LiteralControl 22 0 0
ctl00$SiteMapDataSource1 System.Web.UI.WebControls.SiteMapDataSource 0 0 0
ctl00$ctl07 System.Web.UI.LiteralControl 123 0 0
ctl00$ContentPlaceHolder1 System.Web.UI.WebControls.ContentPlaceHolder 962 0 0
ctl00$ContentPlaceHolder1$ctl00 System.Web.UI.LiteralControl 193 0 0
ctl00$ContentPlaceHolder1$TextBox1 System.Web.UI.WebControls.TextBox 123 0 0
ctl00$ContentPlaceHolder1$ctl01 System.Web.UI.LiteralControl 1 0 0
ctl00$ContentPlaceHolder1$Button1 System.Web.UI.WebControls.Button 323 0 0
ctl00$ContentPlaceHolder1$ctl02 System.Web.UI.LiteralControl 15 0 0
ctl00$ContentPlaceHolder1$SqlDataSource1 System.Web.UI.WebControls.SqlDataSource 0 64 0
ctl00$ContentPlaceHolder1$ctl03 System.Web.UI.LiteralControl 26 0 0
ctl00$ContentPlaceHolder1$GridView1 System.Web.UI.WebControls.GridView 241 120 8
ctl00$ContentPlaceHolder1$GridView1$ctl00 System.Web.UI.WebControls.ChildTable 226 0 0
ctl00$ContentPlaceHolder1$GridView1$ctl01 System.Web.UI.WebControls.GridViewRow 73 0 0
ctl00$ContentPlaceHolder1$GridView1$ctl01$ctl00 System.Web.UI.WebControls.TableCell 56 0 0
ctl00$ContentPlaceHolder1$ctl04 System.Web.UI.LiteralControl 40 0 0
ctl00$ctl08 System.Web.UI.LiteralControl 78 0 0
ctl00$ctl09 System.Web.UI.LiteralControl 20 0 0
Session State
Session Key Type Value
Application State
Application Key Type Value
Request Cookies Collection
Name Value Size
Response Cookies Collection
Name Value Size
Headers Collection
Name Value
Cache-Control no-cache
Connection Keep-Alive
Content-Length 2021
Content-Type application/x-www-form-urlencoded
Accept image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*
Accept-Encoding gzip, deflate
Accept-Language en-us
Host localhost:1872
Referer http://localhost:1872/KPR2/StaffMaint.aspx
User-Agent Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; ..NET CLR 1.1.4322; .NET CLR 2.0.50727; InfoPath.1)
Response Headers Collection
Name Value
X-AspNet-Version 2.0.50727
Cache-Control private
Content-Type text/html
Form Collection
Name Value
ctl00_TreeView1_ExpandState eenenn
ctl00_TreeView1_SelectedNode ctl00_TreeView1t1
__EVENTTARGET
__EVENTARGUMENT
ctl00_TreeView1_PopulateLog
__VIEWSTATE /wEPDwUKMTAyMTc1MTQwMA9kFgJmD2QWAgIDD2QWBAIBDzwrAAkCAA8WCB4NTmV2ZXJFeHBhbmRlZGQeC18hRGF0YUJvdW5kZx4MU2VsZWN0ZWROb2RlBRFjdGwwMF9UcmVlVmlldzF0MR4JTGFzdEluZGV4AgZkCBQrAAIFAzA6MBQrAAIWEh4FVmFsdWUFCkFkbWluIEhvbWUeCURhdGFCb3VuZGceBFRleHQFCkFkbWluIEhvbWUeC05hdmlnYXRlVXJsBRIvS1BSMi9kZWZhdWx0LmFzcHgeCVBvcHVsYXRlZGceCEV4cGFuZGVkZx4HVG9vbFRpcAUYQWRtaW5pc3RyYXRpdmUgSG9tZSBQYWdlHghEYXRhUGF0aAUSL2twcjIvZGVmYXVsdC5hc3B4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eDUVtcHR5RGF0YVRleHQFG05vIHJlY29yZHMgZm91bmQgZm9yIGtjb29rMWRkGAIFHl9fQ29udHJvbHNSZXF1aXJlUG9zdEJhY2tLZXlfXxYBBQ9jdGwwMCRUcmVlVmlldzEFI2N0bDAwJENvbnRlbnRQbGFjZUhvbGRlcjEkR3JpZFZpZXcxD2dkphpo6M9kC2jTd3ndjbQuWZABOVY=
ctl00$ContentPlaceHolder1$TextBox1 dlongnecker
__PREVIOUSPAGE 7omr-D_Vb0kIBrp-ZrqMfriIXa2vqKO7aVkkA5pPXIY1
__EVENTVALIDATION /wEWAwLpmePFBgLc3uCnBAKA4sljJcvxNNggMf0+0y+gi64XvK2yLfI=
Querystring Collection
Name Value
Server Variables
Name Value
ALL_HTTP HTTP_CACHE_CONTROL:no-cache HTTP_CONNECTION:Keep-Alive HTTP_CONTENT_LENGTH:2021 HTTP_CONTENT_TYPE:application/x-www-form-urlencoded HTTP_ACCEPT:image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */* HTTP_ACCEPT_ENCODING:gzip, deflate HTTP_ACCEPT_LANGUAGE:en-us HTTP_HOST:localhost:1872 HTTP_REFERER:http://localhost:1872/KPR2/StaffMaint.aspx HTTP_USER_AGENT:Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; ..NET CLR 1.1.4322; .NET CLR 2.0.50727; InfoPath.1)
ALL_RAW Cache-Control: no-cache Connection: Keep-Alive Content-Length: 2021 Content-Type: application/x-www-form-urlencoded Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */* Accept-Encoding: gzip, deflate Accept-Language: en-us Host: localhost:1872 Referer: http://localhost:1872/KPR2/StaffMaint.aspx User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; InfoPath.1)
APPL_MD_PATH
APPL_PHYSICAL_PATH E:\Projects\KPR2\
AUTH_TYPE NTLM
AUTH_USER [Domain]\dlongnecker
AUTH_PASSWORD
LOGON_USER [Domain]\dlongnecker
REMOTE_USER [Domain]\dlongnecker
CERT_COOKIE
CERT_FLAGS
CERT_ISSUER
CERT_KEYSIZE
CERT_SECRETKEYSIZE
CERT_SERIALNUMBER
CERT_SERVER_ISSUER
CERT_SERVER_SUBJECT
CERT_SUBJECT
CONTENT_LENGTH 2021
CONTENT_TYPE application/x-www-form-urlencoded
GATEWAY_INTERFACE
HTTPS
HTTPS_KEYSIZE
HTTPS_SECRETKEYSIZE
HTTPS_SERVER_ISSUER
HTTPS_SERVER_SUBJECT
INSTANCE_ID
INSTANCE_META_PATH
LOCAL_ADDR 127.0.0.1
PATH_INFO /KPR2/StaffMaint.aspx
PATH_TRANSLATED E:\Projects\KPR2\StaffMaint.aspx
QUERY_STRING
REMOTE_ADDR 127.0.0.1
REMOTE_HOST 127.0.0.1
REMOTE_PORT
REQUEST_METHOD POST
SCRIPT_NAME /KPR2/StaffMaint.aspx
SERVER_NAME localhost
SERVER_PORT 1872
SERVER_PORT_SECURE 0
SERVER_PROTOCOL HTTP/1.1
SERVER_SOFTWARE
URL /KPR2/StaffMaint.aspx
HTTP_CACHE_CONTROL no-cache
HTTP_CONNECTION Keep-Alive
HTTP_CONTENT_LENGTH 2021
HTTP_CONTENT_TYPE application/x-www-form-urlencoded
HTTP_ACCEPT image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*
HTTP_ACCEPT_ENCODING gzip, deflate
HTTP_ACCEPT_LANGUAGE en-us
HTTP_HOST localhost:1872
HTTP_REFERER http://localhost:1872/KPR2/StaffMaint.aspx
HTTP_USER_AGENT Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; InfoPath.1)
 
D

David R. Longnecker

Just to verify, I ensured the syntax worked in SQL Plus; replacing the
:TEXTBOX variable with the string the textbox should be providing.

1* SELECT staff_id, AD_ID, ESIS_ID, SCHOOL_ID, ACCESS_ID FROM staff where
AD_ID = 'dlongnecker'
SQL> /

STAFF_ID AD_ID ESIS_ID
SCHOOL_ID ACCESS_ID
---------- -------------------------------------------------- ---------- ----------
 
K

Kevin Yu [MSFT]

Hi David,

I mean to use the trace tool of the database server to track the actions
performed on server. Just like the SQL Profiler in SQL Server. We can see
if the parameter has been passed correctly using that.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top