利用连接线
"Provider=SQLOLEDB;Data Source=localhost;User ID=foo;password=bar;Database=CodeLists;Pooling=true;Min Pool Size=20;Max Pool Size=30;"
我得到以下痕迹:
System.Data.OleDb.OleDbException: No error message available, result code: -2147024770(0x8007007E). at System.Data.OleDb.OleDbServicesWrapper.GetDataSource(OleDbConnectionString constr, DataSourceWrapper& datasrcWrapper) at System.Data.OleDb.OleDbConnectionInternal..ctor(OleDbConnectionString constr, OleDbConnection connection)
at System.Data.OleDb.OleDbConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningObject) at System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup) at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) at System.Data.OleDb.OleDbConnection.Open()
即便我把服务器URL从当地托管改为无效的hkfjhuidhf,我也得出了这一错误,因此,我假定服务器上出现有关OlegDb连接/设立和(或)发展援助委员会的问题。
服务器是Windows 2003, 运行最新服务包,而MDAC是2.82。
使用Im的代码是:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void run_Click(object sender, EventArgs e)
{
output.Text = string.Empty;
try
{
OleDbConnection connection;
try
{
connection = new OleDbConnection(conString.Text);
}
catch (Exception ex)
{
MessageBox.Show("Error creating connection");
put(ex.ToString());
return;
}
OleDbCommand command;
try
{
command = connection.CreateCommand();
}
catch (Exception ex)
{
MessageBox.Show("Error creating command");
put(ex.ToString());
return;
}
command.CommandType = CommandType.Text;
command.CommandText = "select top 10 * from " + table.Text;
if (connection.State != ConnectionState.Open)
connection.Open();
OleDbDataReader reader;
try
{
reader = command.ExecuteReader();
if (reader.HasRows)
{
string @out = string.Empty;
while (reader.Read())
{
for (int i = 0; i < reader.FieldCount; i++)
{
@out += reader[i] + ", ";
}
}
put(@out);
}
reader.Close();
}
catch (Exception ex)
{
put(ex.ToString());
}
finally
{
connection.Close();
}
}
catch (Exception ex)
{
put(ex.ToString());
}
}
private void put(string message)
{
output.Text += message+Environment.NewLine;
}
}
与此相关。 开放()
是否有任何想法? 然而,我已读到与发援会2.8分辨率第2类的某些条款。 净额代码。
任何和所有投入都受到热烈欢迎。