I have correct path but still get this System.Data.SqlClient.SqlException (0x80131904) RRS feed

  • Question

  • Hi newbie here. It has been some time, could not remember the whole process of installation the SQL Server 2008/ SQL Server 2008R2.

    These are the Instances I found in in C-Drive currently:

    a)  in Program Files(x86)
    1) I have : MSSQL10_50.DEVSQLEXPRESS

    b)  in Program files
    - I have :

    Some how, DEVSQLEXPRESS does not show up in SSMS (from SQL Server 2008 R2) and I can not delete it.

    Now I am using DEVSQLEXPRESS2 for Asp.net Web Api for local testing purpose and development.

    This is my code. No compilation error.

    public User Add(User contact)

     SqlConnection conn = new SqlConnection(
                     "Data Source= .\\DEVSQLEXPRESS2;Initial Catalog=MyBookingHub;Integrated Security=SSPI");
       SqlCommand sqlCmd = new SqlCommand();
       sqlCmd.CommandType = CommandType.Text;
       sqlCmd.CommandText = "INSERT INTO Users (UserName,UserPassword,UserEmailAddr,UserMobile) Values (@UserName,@UserPassword,@UserEmailAddr,@UserMobile)";
                    sqlCmd.Connection = conn;

        sqlCmd.Parameters.AddWithValue("@UserName", contact.UserName);
        sqlCmd.Parameters.AddWithValue("@UserPassword", contact.UserPassword);
        sqlCmd.Parameters.AddWithValue("@UserEmailAddr", contact.UserEmailAddr);
        sqlCmd.Parameters.AddWithValue("@UserMobileNo", contact.UserMobileNo);
        int rowInserted = sqlCmd.ExecuteNonQuery();

        var ctc = new User()
            UserId = rowInserted,
            UserName = contact.UserName,
            UserPassword = contact.UserPassword,
            UserEmailAddr =contact.UserEmailAddr,
            UserMobileNo = contact.UserMobileNo
         return ctc;
       catch (Exception ex)
            string err = ex.ToString();
           return null;  


    This the problem encountered:

    System.Data.SqlClient.SqlException (0x80131904): Incorrect syntax near ' '.
       at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
       at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
       at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
       at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
       at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString, Boolean isInternal, Boolean forDescribeParameterEncryption)
       at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, Boolean inRetry, SqlDataReader ds, Boolean describeParameterEncryptionRequest)
       at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry)
       at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry)
       at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
       at MyBookingService.DataAccessModelRepository.UserRepository.Add(User contact) in C:\Users\Edward\Documents\Visual Studio 2015__AspNet_Web_Api\MyBookingService\MyBookingService\DataAccessModelRepository\UserRepository.cs:line 82
    Error Number:102,State:1,Class:15

    Thanks. You help is much needed to guide me to the correct direction.

    Sunday, April 30, 2017 2:36 AM

All replies

  • The stack trace suggests the INSERT query failed but I don't see how the INSERT statement would fail with the "Incorrect syntax near ' '" error. Is there perhaps an insert trigger on the table? Can you insert from SSMS?

    Dan Guzman, Data Platform MVP, http://www.dbdelta.com

    Sunday, April 30, 2017 5:10 PM
  • Hi FireDance,


    The error message '0x80131904' always occurs on the SQL Server side. This problem can be caused by that the instance is missing or the TCP/IP is disabled.


    According to your description, you cannot find DEVSQLEXPRESS from SSMS, can you check that if you have uninstalled this instance? You can use installed SQL Server features discovery report to check it. Please open SQL Server Installation Center in the Start menu, then open Tools -> Installed SQL Server features discovery report.


    Best Regards,



    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, May 1, 2017 2:21 AM