using ntext fields in filter criteria

I use VB6 and Sql server, when i used this code :-

rscabasho.Filter = "(jawaab is null and kusocota ='" & st & "')  or (katimi='" & st & "' and jawaab<>'') "

Jawaab is ntext field, if i use any other field works well, as well if i use the field jawaab with = operator it works , but this can't be used , since  it could be a NULL value.

Then I encountered this message:-
3001/ argoments are of the wrog type, are out of the acceptable range , or are inconflict with one another

pls i need your suggestions.

M. roble
Who is Participating?
danblakeConnect With a Mentor Commented:
You cannot perform a = '' or <> for ntext fields.

You would need to patern search for values using:
Returns the starting position of the first occurrence of a pattern in a specified expression, or zeros if the pattern is not found, on all valid text and character data types.

PATINDEX ( '%pattern%' , expression )

or alternativly the charindex string search :
The CHARINDEX and PATINDEX functions return the starting position of a pattern you specify. PATINDEX can use wildcard characters while CHARINDEX cannot.

From BOL.
maybe something like this:

rscabasho.Filter = "(jawaab is null and kusocota ='" & st & "')  or (katimi='" & st & "' and jawaab<>'') or  (katimi='" & st & "' and jawaab is not null)  "
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.