09-数据库操作/通用数据库连接/DatabaseCon/Form2.cs

(完整代码) 1KB

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace DatabaseCon
{
    public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
        }
        public static string strServer = "";
        private void Form2_Load(object sender, EventArgs e)
        {
            listBox1.Items.Clear();
            SQLDMO.Application SQLServer = new SQLDMO.Application();
            SQLDMO.NameList strServer = SQLServer.ListAvailableSQLServers();
            if (strServer.Count > 0)
            {
                for (int i = 0; i < strServer.Count; i++)
                {
                    listBox1.Items.Add(strServer.Item(i + 1));
                }
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (listBox1.SelectedIndices.Count == 0)
                MessageBox.Show("请选择要连接的服务器!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            else
            {
                this.Close();
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            strServer = listBox1.Text;
        }
    }
}

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读 AI

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。