sqlconnection的Open为什么会提示错误
string connctString = "workstation id=192.168.0.147;packet size=4096;User Id=sa;Password=sa;data source=192.168.0.147;initial catalog=cti";
try
{
sqlConnection= new SqlConnection(connectString);
sqlConnection.Open();
sqlCommand = new SqlCommand();
sqlCommand.Connection = sqlConnection;
}
catch(Exception e)
{
MessageBox.Show(e.ToString());
return -1;
}
就这么简单的代码,结果说未将对象引入放到实例。完整错误代码如下,我在别的电脑都可以用,而且在别的电脑也可以访问这台电脑的Sqlserver,惟独在这台电脑谁的sqlserver也访问不了,这是什么原因?
"System.NullReferenceException: 未将对象引用设置到对象的实例。\r\n at LoadLibraryW(UInt16* ) at System.EnterpriseServices.Thunk.Security.Init() at System.EnterpriseServices.Thunk.Security.SuspendImpersonation() at System.EnterpriseServices.Platform.Initialize() at System.EnterpriseServices.Platform.get_W2K() at System.EnterpriseServices.ResourcePool..ctor(TransactionEndDelegate cb) at System.Data.SqlClient.ConnectionPool.CreateResourcePool() at System.Data.SqlClient.ConnectionPool..ctor(DefaultPoolControl ctrl) at System.Data.SqlClient.PoolManager.FindOrCreatePool(DefaultPoolControl ctrl) at System.Data.SqlClient.SqlConnectionPoolManager.GetPooledConnection(SqlConnectionString options, Boolean& isInTransaction) at System.Data.SqlClient.SqlConnection.Open() at HWT.WConnect.button2_Click(Object sender, EventArgs e) in d: