How to get list of all database from sql server in a combobox using c#.net

前端 未结 6 1050
北荒
北荒 2020-12-13 16:14

I am entering the source name userid and password through the textbox and want the database list should be listed on the combo box so that all the four options sourcename, u

6条回答
  •  渐次进展
    2020-12-13 16:32

    Simply using GetSchema method:

    using (SqlConnection connection = GetConnection())
    {
        connection.Open();
        DataTable dtDatabases = connection.GetSchema("databases");
    
        //Get database name using dtDatabases["database_name"]
    }
    

提交回复
热议问题