c#里中打开那个数据库连接配置对话框并把连接字符串读出来

一定要引用:
Microsoft ActiveX Data Objects 2.7
Microsoft OLEDB Service Component 1.0 Type Library
 1private void button1_Click(object sender, System.EventArgs e)
 2        {
 3            MSDASC.DataLinks mydlg = new MSDASC.DataLinks();
 4            ADODB._Connection ADOcon;
 5
 6            //Cast the generic object that PromptNew returns to an ADODB._Connection.
 7            ADOcon = (ADODB._Connection) mydlg.PromptNew();
 8
 9            ADOcon.Open("","","",0);
10
11            if (ADOcon.State == 1
12            {
13                MessageBox.Show("Connection Opened" + ADOcon.ConnectionString);
14                ADOcon.Close();
15            }

16            else 
17            {
18                MessageBox.Show("Connection Failed");
19            }

20        }

posted on 2006-04-12 14:27    阅读(741)  评论(0编辑  收藏  举报

导航