×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

ERROR in Assigment

ERROR in Assigment

ERROR in Assigment

(OP)
HI
I have a Pervasive database with a table that one of the columns is a masked textbox .
I'm trying to retreave the information on the mask cell using a SUBSTING Function.
It seams to work fine when just using the substring to return the values (column a,b,c,d) but I get the error in assigment when applying an IF Function with the substring in Pervasive And ERROR In Row In VB.NET.
The table you see in the attachment is data retrived using the substring alone (the first two substrings in my query.
Can you help me with this Query.

CODE -->

SELECT
  limsk.MASK AS p22msk,
 SUBSTRING(limsk.MASK, 41, 2)as a,SUBSTRING(limsk.MASK, 41, 4) AS b,
  SUBSTRING(limsk.MASK, 58, 2) as c,SUBSTRING(limsk.MASK, 58, 4) AS  D,
if (SUBSTRING(limsk.MASK, 41, 2)='__' , 0, SUBSTRING(limsk.MASK, 41, 4) )AS P22xtra,
if (SUBSTRING(limsk.MASK, 58, 2)='__' ,0, SUBSTRING(limsk.MASK, 58, 4) ) As P21Xtra
FROM
  CWLIVEWB.OELI_WB_MASK AS limsk
WHERE
  limsk.FIELD_NAME = 'P22Extra' AND
  limsk.OELI_ORDER_NO LIKE '%0000707956' 

Thanks in Advance.

RE: ERROR in Assigment

THe problem is in your IF statement. You can't have the True part be an integer and the False part be a string. You should be able to change the query to:

CODE

SELECT
  limsk.MASK AS p22msk,
 SUBSTRING(limsk.MASK, 41, 2)as a,SUBSTRING(limsk.MASK, 41, 4) AS b,
  SUBSTRING(limsk.MASK, 58, 2) as c,SUBSTRING(limsk.MASK, 58, 4) AS  D,
if (SUBSTRING(limsk.MASK, 41, 2)='__' , '0', SUBSTRING(limsk.MASK, 41, 4) )AS P22xtra,
if (SUBSTRING(limsk.MASK, 58, 2)='__' ,'0', SUBSTRING(limsk.MASK, 58, 4) ) As P21Xtra
FROM
  CWLIVEWB.OELI_WB_MASK AS limsk
WHERE
  limsk.FIELD_NAME = 'P22Extra' AND
  limsk.OELI_ORDER_NO LIKE '%0000707956' 

Which makes the "True" part being a string with 0 in it.

Mirtheil
http://www.mirtheil.com

RE: ERROR in Assigment

(OP)
Thanks Mirtheil for the help

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close