Verify your SQL statement, watch those quotes before the % sign it should be in the form of LIKE '%VALUE%', not like '%'VALUE'%', you are using double quotes! Just use a quote before the first % and one quote after the last %.
Im assuming your OBJCAT is a number and anything inside the textbox is a string. Oracle will definitely complain. I don't know if this would cause any issues but you could add a to_char() function to your OBJCAT. That way you will compare a string to
varchar.
SelectCommand="SELECT "OBJCAT" FROM "OBJ_MASTER" WHERE ("TO_CHAR(OBJCAT)" LIKE '%' + :OBJCAT + '%')">
<SelectParameters>
<asp:QueryStringParameter Name="OBJCAT" QueryStringField="TextBox1"
Type="String" />
</SelectParameters>
None
0 Points
6 Posts
GridView SelectCommand syntax for Oracle?
Jun 24, 2010 09:38 AM|stephen_mc|LINK
I'm trying to use a 'Like' statement in my SelectCommand string for a GrdiView control (Database is Oracle).I keep getting Oracle errors though.
Here's the Select string code written by Visual Web Developer: -
=============================================
SelectCommand="SELECT "OBJCAT" FROM "OBJ_MASTER" WHERE ("OBJCAT" LIKE '%' + :OBJCAT + '%')">
<SelectParameters>
<asp:QueryStringParameter Name="OBJCAT" QueryStringField="TextBox1"
Type="String" />
</SelectParameters>
=============================================
I think the problem is in this part of the SelectCommand: LIKE '%' + :OBJCAT + '%'
The Oracle error I'm getting is:
ORA-01722: invalid number
Can anyone help me?
Member
14 Points
77 Posts
Re: GridView SelectCommand syntax for Oracle?
Jul 06, 2010 07:58 PM|fperezhn|LINK
Verify your SQL statement, watch those quotes before the % sign it should be in the form of LIKE '%VALUE%', not like '%'VALUE'%', you are using double quotes! Just use a quote before the first % and one quote after the last %.
Member
35 Points
52 Posts
Re: GridView SelectCommand syntax for Oracle?
Jul 07, 2010 02:27 PM|aspnoob07|LINK
Im assuming your OBJCAT is a number and anything inside the textbox is a string. Oracle will definitely complain. I don't know if this would cause any issues but you could add a to_char() function to your OBJCAT. That way you will compare a string to varchar.
SelectCommand="SELECT "OBJCAT" FROM "OBJ_MASTER" WHERE ("TO_CHAR(OBJCAT)" LIKE '%' + :OBJCAT + '%')">
<SelectParameters>
<asp:QueryStringParameter Name="OBJCAT" QueryStringField="TextBox1"
Type="String" />
</SelectParameters>
I could be way off here but just a thought.
Hope it helps.