大家好,
我使用VS2010的远程计算机上的连接到SQLServer 2000实例。
我用的是OLEDB连接字符串是不会打开。我想知道如果任何人都可以阐明为什么就此将无法打开一些轻。任何帮助是极大的赞赏。谢谢!
下面的代码。
public string RDDTConnectionString = @"Provider=sqloledb;Data Source=MyServer;Initial Catalog=MyDataBase;Integrated Security=SSPI;";
public OleDbConnection ConnString()
{
OleDbConnection connString = new OleDbConnection();
connString.ConnectionString = RDDTConnectionString;
return connString;
}
private void btnSaveDealSheet_Click(object sender, EventArgs e)
{
try
{
if (ConnString().State == ConnectionState.Closed)
{
ConnString().Open();
MessageBox.Show("ConnString.State:" + ConnString().State);
}
//Execute SQL
OleDbCommand InsertCommand = GetInsertDealSheetCommand();
InsertedID = Convert.ToInt32(InsertCommand.ExecuteScalar());
//Return inserted Identity
MessageBox.Show("DealSheet Successfully Added");
}
catch (Exception ex)
{
MessageBox.Show("error: " + ex.Message); ;
}
}
public void OpenConnectionString()
{
try
{
ConnString().Open();
if (ConnString().State == ConnectionState.Open)
{
MessageBox.Show("opened");
}
}
catch (Exception ex)
{
MessageBox.Show("Error: " + ex.Message);
}
}