is it ok this connection string for access since any computer (using Internet)
well I need to have access since another place (using internet) but I don't have another PC for I see if this is OK ... I do have the connection since here myself computer, but I am going to need if I have a connection since another computer to my database, or do you know any anothe开发者_如何学运维r form? (it is for a windows application)
here my class connection because you watch if it is ok..
namespace Coneccion
{
class Conexion
{
public SqlConnection conectar()
{
SqlConnection con = new SqlConnection(@"Data Source=server,1433;Failover Partner=ip;Initial Catalog=database;Persist Security Info=True;User ID=login; Password=password; Asynchronous Processing=True;TrustServerCertificate=True;Network Library=dbmssocn;Workstation ID=pc;User Instance=False");
return con;
}
public void EjecutarConsulta(SqlCommand comando)
{
comando.Connection.Open(); // abrimos la conexion
comando.ExecuteNonQuery(); // ejecutamos la consulta
comando.Connection.Close(); // y cerramos la conexion
}
}
}
Maybe this code getting some error in another computer.
TrustServerCertificate=True
But rest of the code is OK.
also
using(var cmd = connection.CreateCommand()){
cmd.Open();
// do some query.
} // using will automatic close the command
精彩评论