Local database . MDF C# Visual Studio 2017 (CONNECTION)

Asked

Viewed 788 times

0

I am developing a windows application using visual studio 2017, but I came across a problem, on my machine that I am doing the project everything runs right, on the other machine that I do the tests of connection error with the bank, I have installed the correct version of . NET and SQL SERVER, I dropped the folder in the same place as the other machine on disk C:. I am using the app.config for connection to the database. I find it strange the connection does not need user and password of the bank (I’m still learning C# and knowing the visual studio).

Obs I am programming on a machine with windows 10 and testing and other machine with windows 7

App.Config

<configuration>
    <configSections>
    </configSections>
    <connectionStrings>
        <add name="conn"
            connectionString="Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Sistema\Sistema.mdf;Integrated Security=True"
            providerName="System.Data.SqlClient" />
    </connectionStrings>
    <startup> 
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
    </startup>  
</configuration>

That is the mistake:

************** Texto de Exceção **************
System.Data.SqlClient.SqlException (0x80131904): Erro de rede ou específico à instância ao estabelecer conexão com o SQL Server. O servidor não foi encontrado ou não estava acessível. Verifique se o nome da instância está correto e se o SQL Server está configurado para permitir conexões remotas. (provider: SQL Network Interfaces, error: 26 - Erro ao Localizar Servidor/Instância Especificada)
   em System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
   em System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning()
   em System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity)
   em System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, SqlConnection owningObject)
   em System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, TimeoutTimer timeout)
   em System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, TimeoutTimer timeout, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance)
   em System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance)
   em System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection)
   em System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options)
   em System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject)
   em System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject)
   em System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject)
   em System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
   em System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
   em System.Data.SqlClient.SqlConnection.Open()
   em WindowsFormsApp1.formLogin.acessar_Click(Object sender, EventArgs e) na C:\Sisgemp\formLogin.cs:linha 44
   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)
  • You have already given permission in the folder where . mdf of the computer does not connect?

  • Very likely the file does not exist at this address on the other machine: C:\Sistema\Sistema.mdf

  • worst there is, I copied the C project folder from one machine to the C of the other, checked and the path is equal

  • The permissions for the folder, only that I think it’s something in my connection, in no time I informed bank password or anything. I have doubts about that.

No answers

Browser other questions tagged

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