Connection Sql Server Database . MDF does not work C#

Asked

Viewed 442 times

0

My error application when I try to run on another machine, only on this machine I have nothing sql server installed, what I need to run my application on any pc?

Follow the error:

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)
  • Could you add the connection string you used? It is necessary that the SQL Server client software is installed on the computer where the application will be executed.

  • what would be the SQL Server client software? It has some download link?

  • Sqlconnection Conn = new Sqlconnection(@"Data Source=(Localdb) Mssqllocaldb;Attachdbfilename=C: Sisgemp Sisgemp.mdf;Integrated Security=True");

1 answer

0


The problem is that the program is waiting for the base (mdf file) in a location on the machine where the program is running.

In order for the programme to be implemented any machine, the bank must be accessible by any machine.

To do this, you must install the SQL Server server, which is owned by Microsoft (and is not free) : https://www.microsoft.com/pt-br/sql-server/sql-server-downloads

  • 2

    Express edition of SQL Server is free.

Browser other questions tagged

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