SqlConnection con = new SqlConnection("server=192.168.0.100,1400;user=Users;password=password;database=Example1;integrated security = true;");
SqlDataAdapter sda = new SqlDataAdapter();
DataTable dbdataset = new DataTable();
BindingSource bsource = new BindingSource();
SqlCommand cmd = new SqlCommand();
public void loaddata()
{
try
{
SqlCommand cmdatabbase = new SqlCommand(" select * from Example1.dbo.Users ;", con);
sda.SelectCommand = cmdatabbase;
sda.Fill(dbdataset);
bsource.DataSource = dbdataset;
dataGridView1.DataSource = bsource;
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
这是我在C#Winforms应用程序中的代码。在我的计算机上它正在工作,但是从另一台计算机上它显示错误(它无法在datagridview中加载表)。我在防火墙中添加了规则,并在SQL Server配置管理器中启用了tcp,但它仍然无效!我尝试了在互联网上找到的所有解决方案,但它没有用。
a busy cat http://non-98.ucoz.com/Untitled5.jpg
我在运行程序时在另一台计算机上看到了这个。
答案 0 :(得分:1)
您必须将integrated security
从true
更改为false
。请检查此connection strings
答案 1 :(得分:0)
我认为这是由于服务器的可访问性。尝试集成安全性= False或更新连接字符串