DataConnectionDialog dia = new DataConnectionDialog();
DataSource.AddStandardDataSources(dia);
dia.SelectedDataSource = DataSource.SqlDataSource;
dia.SelectedDataProvider = DataProvider.SqlDataProvider;
if (DataConnectionDialog.Show(dia, this) == DialogResult.OK)
{
string myConnect = dia.ConnectionString;
MessageBox.Show(myConnect);
}
但是,当我把程序改成
DataConnectionDialog connectionDialog = new DataConnectionDialog();
DataSource.AddStandardDataSources(connectionDialog);
DataSource npgDataSource = new DataSource("PostgreSql", "PostgreSQL");
DataProvider npgDataProvider = new DataProvider("Npgsql Provider", ".Net Framework Data Provider for Npgsql", "Npgsql");
npgDataSource.Providers.Add(npgDataProvider);
connectionDialog.DataSources.Add(npgDataSource);
connectionDialog.SelectedDataSource = npgDataSource;
connectionDialog.SelectedDataProvider = npgDataProvider;
if (DataConnectionDialog.Show(connectionDialog,this) == DialogResult.OK)
{
string myConnectionString = connectionDialog.ConnectionString;
MessageBox.Show(myConnectionString);
}
程序不会弹出那个内置的对话框。请问,配置Pg数据库的时候能够还能够弹出内置的对话框吗,如果可以程序该怎么改呢?
1 个解决方案
#1
应该也是支持的,是不是你的数据驱动没有装或者配置好。
#1
应该也是支持的,是不是你的数据驱动没有装或者配置好。