Click here to Skip to main content
15,904,348 members
Please Sign up or sign in to vote.
2.50/5 (2 votes)
See more:
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.
Posted
Comments
Mehdi Gholam 25-Apr-14 1:50am    
Show your query in cmd.
Er Daljeet Singh 25-Apr-14 2:06am    
Check the name of the table in database your database there is spelling mistake in it.
RahulAhire26 25-Apr-14 4:37am    
i have checked there is no spelling mistake
Herman<T>.Instance 25-Apr-14 7:50am    
As I look to the given solutions and you keep stating that the error is not solved. It looks like your connectionstring is missing the Catalogname. It might try to find the Registration table in Master db. Please check your connectionstring contents.

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
 
Share this answer
 
Comments
RahulAhire26 25-Apr-14 6:18am    
the error has not been solved. the Error occurs in the line:- da.Fill(ds, "Registration");
Am i using wrong syntax?
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....
 
Share this answer
 
Comments
RahulAhire26 25-Apr-14 4:29am    
the code i wrote was as follows:-

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(cmd);
da.SelectCommand = cmd;
DataSet ds = new DataSet();
da.Fill(ds,"Registration");
SqlCommandBuilder cb = new SqlCommandBuilder(da);
DataRow drow = ds.Tables["Registration"].NewRow();
i have use Registration as my table name.
Before line 28 code as below

C#
SqlDataAdapter da =  new SqlDataAdapter(cmd);
 
Share this answer
 
Comments
RahulAhire26 25-Apr-14 4:31am    
it didn't worked for me the error is still there.
The problem was related to database. There was mistake in the connection string of sql that is in the web.config page. As the connection was corrected the error was resolve automatically.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900