如何解决与Sql无效对象名称“注册”相关的错误。 [英] How Do I Solve The Error Related To Sql Invalid Object Name 'Registration'.

查看:84
本文介绍了如何解决与Sql无效对象名称“注册”相关的错误。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

发生以下错误: -

无效的对象名称'注册'。



描述:执行期间发生了未处理的异常当前的网络请求。请查看堆栈跟踪以获取有关错误及其源自代码的位置的更多信息。



异常详细信息:System.Data.SqlClient.SqlException:无效的对象名称'Registration'。



来源错误:





第27行:da.SelectCommand = cmd;

第28行:DataSet ds = new DataSet();

第29行:da.Fill(ds);

第29行出错:da.Fill(ds);

请帮我解决这个问题。

解决方案

只需使用下面的代码



 SqlConnection cnn = new SqlConnection(); 
cnn.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings [sqlconnection]。ConnectionString;
//cnn.Open();
// SqlCommand cmd = new SqlCommand();
//cmd.CommandText =select * from Registration;
//cmd.Connection = cnn;
SqlDataAdapter da = new SqlDataAdapter(select * from Registration,cnn);
//da.SelectCommand = cmd;
DataSet ds = new DataSet();
da.Fill(ds,Registration);







谢谢,

-RG




您是否在代码中使用任何称为注册的对象...如列名或任何内容....请将代码粘贴到您的位置使用那个....这个错误通常在存储过程不包含该列名时发生....


在第28行代码之前如下



 SqlDataAdapter da =  new  SqlDataAdapter(cmd); 


The following error occurs:-
Invalid object name 'Registration'.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: Invalid object name 'Registration'.

Source Error:


Line 27: da.SelectCommand = cmd;
Line 28: DataSet ds = new DataSet();
Line 29: da.Fill(ds);
There is an error in the line 29: da.Fill(ds);
Please help me out on this issuse.

解决方案

just use code as below

SqlConnection cnn = new SqlConnection();
           cnn.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["sqlconnection"].ConnectionString;
           //cnn.Open();
           //SqlCommand cmd = new SqlCommand();
           //cmd.CommandText = "select * from Registration";
           //cmd.Connection = cnn;
           SqlDataAdapter da = new SqlDataAdapter("select * from Registration",cnn);
           //da.SelectCommand = cmd;
           DataSet ds = new DataSet();
           da.Fill(ds, "Registration");




Thanks,
-RG


Hi,
Did you use any where object called "Registration" in your code... like column name or elase anything.... please paste the code where u have used that one.... this error occusrs generally when the stored procedure does not contain that column name....


Before line 28 code as below

SqlDataAdapter da =  new SqlDataAdapter(cmd);


这篇关于如何解决与Sql无效对象名称“注册”相关的错误。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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