我有一个OLEDB连接,我希望在脚本中动态更改此连接。我使用以下代码获取此OLEDB连接的信息:
ConnectionManager cm = Dts.Connections["VendorDB"];
DbConnection conn = null;
if (cm.CreationName == "OLEDB")
{
Wrap.IDTSConnectionManagerDatabaseParameters100 cmParams =
cm.InnerObject as Wrap.IDTSConnectionManagerDatabaseParameters100;
conn = cmParams.GetConnectionForSchema() as DbConnection;
}
else
{
conn = cm.AcquireConnection(null) as DbConnection;
}
if (conn.State == ConnectionState.Closed)
{
conn.Open();
}
MessageBox.Show(conn.ConnectionString.ToString());
我需要更改此连接信息(比如我想更改初始目录等),并希望此更改的信息保留在整个包中。怎么做?