试图执行存储过程时无效的对象名称错误? [英] Invalid object name error when trying to execute stored procedure?

查看:847
本文介绍了试图执行存储过程时无效的对象名称错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

不知道这笔交易是我的存储过程命名正是我打电话但它总是给我这个无效的对象错误。这里是连接code,错误是在倒数第二行有异常。

  SqlConnection的cnstr =新的SqlConnection(ConfigurationManager.ConnectionStrings [darconn]的ConnectionString);
SQLCMD的SqlCommand =新的SqlCommand();sqlcmd.CommandType = CommandType.StoredProcedure;
sqlcmd.Connection = cnstr;
sqlcmd.CommandText =SetMapping;的String [] = pullKodID bundlelist.SelectedValue.ToString()斯普利特(':');
INT kod_id = System.Convert.ToInt32(pullKodID [0]);sqlcmd.Parameters.Add(@ kod_id,kod_id);
sqlcmd.Parameters.Add(@ ell_id,courselist.Items [I]。文本);
cnstr.Open();
sqlcmd.ExecuteNonQuery();
cnstr.Close();


解决方案

,因为在创建/比之外的用户dbo最有可能的存储过程是不是你的code可见或在连接字符串中指定的用户。

你试过$ P $与 DBO pfixing存储过程的名称?例如,dbo.SetMapping。

如果做不到这一点,使用Management Studio /企业管理器来找出谁拥有的存储过程,要么重新创建为 DBO 或更新您的code /连接字符串使用适当的用户。

Not sure what the deal is I have the stored procedure named exactly what I am calling however it always gives me this invalid object error. Here is the connection code, the error is thrown on the second to last line there.

SqlConnection cnstr = new SqlConnection(ConfigurationManager.ConnectionStrings["darconn"].ConnectionString);
SqlCommand sqlcmd = new SqlCommand();

sqlcmd.CommandType = CommandType.StoredProcedure;
sqlcmd.Connection = cnstr;
sqlcmd.CommandText = "SetMapping";

String[] pullKodID = bundlelist.SelectedValue.ToString().Split(':');
int kod_id = System.Convert.ToInt32(pullKodID[0]);

sqlcmd.Parameters.Add("@kod_id", kod_id);
sqlcmd.Parameters.Add("@ell_id", courselist.Items[i].Text);
cnstr.Open();
sqlcmd.ExecuteNonQuery();
cnstr.Close();

解决方案

Most likely the stored procedure isn't visible to your code because it was created/owned by a user other than dbo or the user specified in your connection string.

Have you tried prefixing the stored procedure name with dbo? For example "dbo.SetMapping".

Failing that, use Management Studio/Enterprise Manager to find out who owns the stored procedure and either recreate it as dbo or update your code/connection string to use the appropriate user.

这篇关于试图执行存储过程时无效的对象名称错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆