zoukankan      html  css  js  c++  java
  • 接口连接到数据库


    1、获取本机的SQL Serverserver名
            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));
                    }
                }
            }
    2、连接特定的数据库
            private void button1_Click(object sender, EventArgs e)
            {
                DBUser.sserver = "."; DBUser.DBName = "Goodluck"; DBUser.suser = "sa"; DBUser.spasswd = "abc";
                MyDBase DB = new MyDBase(DBUser.sserver, DBUser.DBName, DBUser.suser, DBUser.spasswd);
                DataSet DS = DB.GetRecordset("use master;select name as Sname from sysdatabases");
                comboBox1.DataSource = DS.Tables[0];
                comboBox1.DisplayMember = "Sname";
                comboBox1.ValueMember = "Sname";
                DB.DBClose();
            }



    版权声明:本文博客原创文章,博客,未经同意,不得转载。

  • 相关阅读:
    ubuntu故障处理
    最全http状态码
    go故障排查集锦
    docker知识11---docker service
    docker知识10---docker secret
    windows安装mysql
    信息收集
    模块
    Django:中间件
    Django:ORM单表操作
  • 原文地址:https://www.cnblogs.com/blfshiye/p/4756448.html
Copyright © 2011-2022 走看看