任何计算机(使用互联网)都可以访问此连接字符串吗
好吧,我需要从另一个地方(使用互联网)进行访问,但我没有另一台电脑,因为我看看这是否可以...我自己的计算机确实有连接,但如果我有的话,我将需要从另一台计算机到我的数据库的连接,或者您知道任何其他形式吗? (它适用于 Windows 应用程序)
这里是我的类连接,因为你看它是否正常..
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
}
}
}
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 another 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
}
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
也许这段代码在另一台计算机上出现一些错误。
但其余代码没问题。
Maybe this code getting some error in another computer.
But rest of the code is OK.
还
also