none
LINQ to SQL: System.Data.SqlClient.SqlException: Invalid object name 'Users'. RRS feed

  • Question

  • Dear ALL,

    My connection string connects to the right database and the Users table is defined in my dbml. While connecting from LINQ to SQL(on doing a context.submitchanges to the users table), it throws the below error,

    System.Data.SqlClient.SqlException: Invalid object name 'Users'.
       at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
       at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
       at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
       at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
       at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
       at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
       at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
       at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe)
       at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
       at System.Data.Linq.SqlClient.SqlProvider.Execute(Expression query, QueryInfo queryInfo, IObjectReaderFactory factory, Object[] parentArgs, Object[] userArgs, ICompiledSubQuery[] subQueries, Object lastResult)
       at System.Data.Linq.SqlClient.SqlProvider.ExecuteAll(Expression query, QueryInfo[] queryInfos, IObjectReaderFactory factory, Object[] userArguments, ICompiledSubQuery[] subQueries)
       at System.Data.Linq.SqlClient.SqlProvider.System.Data.Linq.Provider.IProvider.Execute(Expression query)
       at System.Data.Linq.ChangeDirector.StandardChangeDirector.DynamicInsert(TrackedObject item)
       at System.Data.Linq.ChangeDirector.StandardChangeDirector.Insert(TrackedObject item)
       at System.Data.Linq.ChangeProcessor.SubmitChanges(ConflictMode failureMode)
       at System.Data.Linq.DataContext.SubmitChanges(ConflictMode failureMode)
       at System.Data.Linq.DataContext.SubmitChanges()
       at EmployeeProfile.Datalayer.User.SaveUser(NameValue[] formData, String CreatedBy) in F:\Projects\EmployeeProfile\User.cs:line 135}

    I also tried removing the 'dbo.' prefix and still no go.

    Please help.


    Many thanks, Balaji Palamadai It would be greatly appreciated if you would mark any helpful entries as helpful and if the entry answers your question, please mark it with the Answer link.

    • Moved by Leo Liu - MSFT Tuesday, March 20, 2012 7:11 AM Moved for better support. (From:Visual C# General)
    Monday, March 19, 2012 2:14 PM

Answers

  •  
    So either you have a object on the model called Users or you don't.
     
    Monday, March 19, 2012 2:30 PM
  • Hi Balaji;

    Please check the name in the database to make sure that the name in the database is Users and NOT User?

     


    Fernando (MCSD)

    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".

    Monday, March 19, 2012 2:31 PM

All replies

  •  
    So either you have a object on the model called Users or you don't.
     
    Monday, March 19, 2012 2:30 PM
  • Hi Balaji;

    Please check the name in the database to make sure that the name in the database is Users and NOT User?

     


    Fernando (MCSD)

    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".

    Monday, March 19, 2012 2:31 PM
  • Well, that was overwhelmly unhelpful. And the mod marked it as an answer?! And Microsoft asks me why I'm dissatisfied...

    G. Steele at Sedgwick

    Friday, June 13, 2014 4:54 PM
  • So, Balaji, did the Brainiacs below every get you an answer? I'm having the same problem and the queries with the same entity name work just fine in SQL Server Studio, so yes, the names are correct and the user account does have access to them. Yet I get the same error.

    G. Steele at Sedgwick

    Friday, June 13, 2014 4:56 PM