开发者

get Invalid object name while executing a UDF

I have written a code block to fetch results based on the keyword.

using (DummyDataContex开发者_StackOverflow社区t vdc = Connection.getContext())
{
  string searchStr = "cricket";
  var _result = from w in vdc.simple_Search(searchStr)
                select w;
  ListView1.DataSource = _result;
  ListView1.DataBind();
}

But, I get an error when the DataBind() operation of the listview is called

Invalid object name 'dbo.simple_Search'.

I have the udf in my database, but don't know why this error is cropping up. Any suggestions.

This is the UDF:

CREATE FUNCTION [dbo].[simple_Search]
(
      @keyword nvarchar(4000)
)
RETURNS TABLE
AS
RETURN
(
      select * from sports where 
      (CONTAINS(sportName, @keyword))
)


Nothing obvious stands out.

Are you 100% sure you are connecting to the correct database?

If you have access to the sql server can you run the check to see what tsql command is being passed to it.

Also try forcing immediate execution to make sure it is not a binding issue

ie

    var _result = from w in vdc.simple_Search(searchStr)
            select w;
    var test = _result.ToList(); 

...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜