现在的位置: 首页 > 综合 > 正文

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

2012年07月14日 ⁄ 综合 ⁄ 共 743字 ⁄ 字号 评论关闭
一定要引用:
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        }

抱歉!评论已关闭.