Error: data provider or other service returned an e_fail status in forms

I have a from and the data source is a store procedure (SQL Server).
What happen is if the store procedure is worte like this (Case 1))
the the form will be run and opened without any issue.
If the store prcedure worte like this (Case 2)
Then I will get an error message: "data provider or other service returned an e_fail status ..."

The logic is whenever the user click on the form, the system should recognize the user's rights and run the code at different region which assiged to.
The problem is if I hardcode the region in the sp, the form will run and no error. But if I put the code and let it caculate the user's region, then the error message will display.

Anyone have idea of this type of error message?

many thanks.
// case 1
select * from 
Tables
where Property_Assignments.Region like 'NE'

Open in new window

select * from 
Tables

    WHERE (
              Property_Assignments.Region 
              Like 
			  (
			   CASE WHEN
						 (
                           (
						    SELECT [User_Region]
						    FROM   Users 
						    WHERE  LTRIM(RTRIM([User_Network_ID])) = @OSUserName
						   ) <> 'ALL'
						 ) 
				    THEN 
						 (SELECT [User_Region]
						  FROM   Users 
						  WHERE  LTRIM(RTRIM([User_Network_ID])) = @OSUserName)
                    ELSE '%'
			   END
			  )
          )

Open in new window

FinghtingMiaoAsked:
Who is Participating?
 
Surone1Commented:
my guess would be it has to do with a reserved word.
do you have a field named "user" in your table by chance?
0
 
FinghtingMiaoAuthor Commented:
NO, the table users have the following fileds: see attached image.


users.JPG
0
 
FinghtingMiaoAuthor Commented:
I found out the problem,
the casewhen statement returns a list of data which is same values. But LIKE does not accept a list of data but one sigle value. so I just added a sub-query for casewhen statement. then the error message gone.

But still thank you for your comments!  
0
 
FinghtingMiaoAuthor Commented:
Still thank you !
0
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.