执行 UDF 时获取无效的对象名称
我编写了一个代码块来根据关键字获取结果。
using (DummyDataContext vdc = Connection.getContext())
{
string searchStr = "cricket";
var _result = from w in vdc.simple_Search(searchStr)
select w;
ListView1.DataSource = _result;
ListView1.DataBind();
}
但是,当调用列表视图的 DataBind() 操作时出现错误
对象名称无效 'dbo.simple_Search'。
我的数据库中有 udf,但不知道为什么会出现此错误。任何建议。
这是 UDF:
CREATE FUNCTION [dbo].[simple_Search]
(
@keyword nvarchar(4000)
)
RETURNS TABLE
AS
RETURN
(
select * from sports where
(CONTAINS(sportName, @keyword))
)
I have written a code block to fetch results based on the keyword.
using (DummyDataContext 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))
)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
没有什么明显的突出之处。
您是否 100% 确定您正在连接到正确的数据库?
如果您有权访问 sql 服务器,您可以运行检查以查看正在传递给它的 tsql 命令。
还尝试强制立即执行以确保它不是一个具有约束力的问题,
即
......
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
...