Database connection error . MDF C# Visual Studio

Asked

Viewed 568 times

0

App.Config

<connectionStrings>
    <add name="conn"
        connectionString="Data Source=.\SQLExpress;AttachDbFilename=C:\Sistema\Sistema.mdf;Integrated Security=True"
        providerName="System.Data.SqlClient" />
</connectionStrings>

Mistake to follow

System.Data.SqlClient.SqlException (0x80131904): O banco de dados 
'C:\SISTEMA\SISTEMA.MDF' não pode ser aberto porque sua versão é a 869.
 Este servidor suporta a versão 782 e anteriores. O caminho de desatualização não é suportado.
Não foi possível abrir o novo banco de dados 'C:\SISTEMA\SISTEMA.MDF'. CREATE DATABASE foi anulado.
Falha na tentativa de anexar um banco de dados autodenominado no arquivo F:\Sisgemp\Sisgemp.mdf. Existe um banco de dados com o mesmo nome, o arquivo especificado não pode ser aberto, ou está localizado em um compartilhamento UNC.
   em System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, DbConnectionPool pool, String accessToken, Boolean applyTransientFaultHandling, SqlAuthenticationProviderManager sqlAuthProviderManager)
   em System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
   em System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions)
   em System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
   em System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
   em System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection)
   em System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection)
   em System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)
   em System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
   em System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
   em System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry)
   em System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
   em System.Data.SqlClient.SqlConnection.Open()
   em WindowsFormsApp1.formLogin.acessar_Click(Object sender, EventArgs e) na C:\Sisgemp\formLogin.cs:linha 50
   em System.Windows.Forms.Control.OnClick(EventArgs e)
   em System.Windows.Forms.Button.OnClick(EventArgs e)
   em System.Windows.Forms.Button.PerformClick()
   em System.Windows.Forms.Form.ProcessDialogKey(Keys keyData)
   em System.Windows.Forms.Control.ProcessDialogKey(Keys keyData)
   em System.Windows.Forms.Control.PreProcessMessage(Message& msg)
   em System.Windows.Forms.Control.PreProcessControlMessageInternal(Control target, Message& msg)
   em System.Windows.Forms.Application.ThreadContext.PreTranslateMessage(MSG& msg)
ClientConnectionId:5f545993-bd51-42bf-870b-e3af757265b7
Error Number:948,State:1,Class:20
  • 1

    Version 782 is a Sql Server 2014 database file, version 706 is a Sql Server 2012 database file, it seems that you are trying a database from a newer version of the database file (SQL Server 2014) to an older version (SQL Serevr 2012 Express). As far as I know, SQL Server 2012 Localdb will no longer be able to use these updated databases for SQL Server 2014 Localdb. Reference: https://social.msdn.microsoft.com/Forums/en-US/8e2c4003-f203-4d4b-8d30-46543700c3bb/visual-studio-server-explorer-error-version-782?forum=linqtosql

  • That’s right, I uninstalled 2012 and installed 2014 and it worked

2 answers

1


Sql Server version, switched from 2012 to 2014 and worked, also fuz an adjustment on the Localdb connection to . Sqlexpress

0

Version 782 is a Sql Server 2014 database file, version 706 is a Sql Server 2012 database file, it seems that you are trying a database from a newer version of the database file (SQL Server 2014) to an older version (SQL Serevr 2012 Express). As far as I know, SQL Server 2012 Localdb will no longer be able to use these updated databases for SQL Server 2014 Localdb.

Reference: https://social.msdn.microsoft.com/Forums/en-US/8e2c4003-f203-4d4b-8d30-46543700c3bb/visual-studio-server-explorer-error-version-782?forum=linqtosql

Browser other questions tagged

You are not signed in. Login or sign up in order to post.