• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 387
  • Last Modified:

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.
Thanks.

M. roble
0
rooble
Asked:
rooble
1 Solution
 
mquirozCommented:
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)  "
0
 
danblakeCommented:
You cannot perform a = '' or <> for ntext fields.

You would need to patern search for values using:
PATINDEX
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.

Syntax
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.
0

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now