473,406 Members | 2,698 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

how to use variable with oracle like

Hi everyone,
Iam trying to use a variable in the where clause of an oracle statement but it isn't working

string cmdQuery = "SELECT A, B, C FROM TESTTABLE WHERE (A LIKE "%" + txtComments.Text + "'%)";

Can anyone tell me what I'm doing wrong? thanks so much in advance
Oct 2 '07 #1
4 11849
Sorry meant to say LIKE % variable %
Oct 2 '07 #2
debasisdas
8,127 Expert 4TB
Try to use

string cmdQuery = "SELECT A, B, C FROM TESTTABLE WHERE A LIKE %" +"'" + txtComments.Text+" '%";

Hope that solves your problem.
Oct 2 '07 #3
Try to use

string cmdQuery = "SELECT A, B, C FROM TESTTABLE WHERE A LIKE %" +"'" + txtComments.Text+" '%";

Hope that solves your problem.
Hiya, thanks for this, below is the actual code (incorporating your suggestion I think) but I'm getting ORA-00911: invalid character :O( have I put a bracket in the wrong place?

string cmdQuery = "SELECT R_EXPEDIOREFERENCE ExpedioRef,R_CUSTOMERREFERENCE Reference,R_TITLE Title, R_REQUESTSTATUS Status, R_REQUESTTASK Task FROM aradmin.exp__request WHERE (r_source = 'KANA' AND R_EXPEDIOREFERENCE LIKE %" + "'" + txtExRef.Text + "'%))";
Oct 2 '07 #4
debasisdas
8,127 Expert 4TB
Why are you using brackets ?

Try this

string cmdQuery = "SELECT R_EXPEDIOREFERENCE ExpedioRef,R_CUSTOMERREFERENCE Reference,R_TITLE Title, R_REQUESTSTATUS Status, R_REQUESTTASK Task FROM aradmin.exp__request WHERE r_source = 'KANA' AND R_EXPEDIOREFERENCE LIKE %" + "'" + txtExRef.Text + "'%"
Oct 2 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Nelson Broat | last post by:
In jsp land you can have the following: <% String name = "Nelson"; %> Hi, my name is <%= name %>. Such that, in your browser you see:
6
by: Florian Marinoiu | last post by:
Hi, I have the following MS-SQL Server statement that I want to convert to ORACLE 8.1 SET @pPhone = '%' + @pPhone + '%' In ORACLE I tried SELECT '%' || pPhone || '%' into pPhone from dual; ...
4
by: Wayne Baswell | last post by:
I want to pass a date variable to a sql statement from Crystal Reports. The part of the query accepting the variables looks like: "Calendar_Date between To_Date('1-JUN-03','mm/dd/yy') and...
1
by: arvee | last post by:
Hi - I'm updating an Oracle table with an empty string and getting the error: An unhandled exception of type 'System.Exception' occurred in system.data.dll Additional information: Parameter...
4
by: Murph | last post by:
Hi, I'm new to ASP.NET and have a problem which i'm hoping will be easy to answer... i have only used VB, HTML and Flash up until now! I am designing an ASP page which uses OleDb to retrieve...
3
by: menglin.cao | last post by:
Hi, I am trying to join two tables, one has multiple records per ID, the other is unique record per ID. The two tables look like below A ID date var1 var 2 001 1/1 10 20 001 2/1 ...
1
by: mm27603 | last post by:
I'm trying to do a simple query of an Oracle 10g database within some vbscript code. <% 'Get protocol information to display in dropdown list %> <!--#include file="dbconnect2.inc"--> <%...
0
by: mikej | last post by:
Hi, I automated a process (using a recordable MACRO) in excell to open msaccess query and retrieve data (from an Oracle database) - said data then to be compared via VLOOKUP with data in a second...
0
by: becksinthecity | last post by:
I'm trying to convert the below SQL into Oracle but am having some issues with the variable declarations. SQL commands declare @sqlstring varchar(500) select @sqlstring= (select ...
9
by: iavian | last post by:
Hi all , I want to set a env variable in a C program? . Not through shell env variables. Any help? Thanks Vijay
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.