如何调用或查看sql server 2000的所有数据库? [英] How Call Or See all Database of sql server 2000?

查看:431
本文介绍了如何调用或查看sql server 2000的所有数据库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在组合框中显示sql server 2000的所有数据库,这意味着该后面的代码是什么

如果在sql server中证明有2个或3个以上的数据库,并且我想在列表中或组合框中显示所有列表,请单击

how can show all database of sql server 2000 in my combo-box mean what will be code behind that

if there are more then 2 or 3 database attested in sql server and i want to show all list in list or in combo box

推荐答案

Try:
Try:
SELECT * FROM information_schema.tables




这是显示所有表,我想显示所有数据库"


糟糕! :O




"this is show all table i want to show all database"


Oops! :O

Dim con As New SqlConnection("Data Source=GRIFFPC\SQLEXPRESS;Integrated Security=True")
con.Open()
Dim cmd As New SqlCommand("sp_databases", con)
cmd.CommandType = CommandType.StoredProcedure
Dim read As SqlDataReader = cmd.ExecuteReader()
While read.Read()
    Console.WriteLine(DirectCast(read("DATABASE_NAME"), String))
End While


您将需要更改实例名称,并且可能需要UID/密码组合而不是集成安全性.


You will need to change teh instance name, and may need a UID/Password combo instead of Integrated Security.


^ ]可能会对您有所帮助.
This[^] might help you.


Dim conn As New SqlConnection(connString) 
Dim strSQL As String = "SELECT name FROM master.sys.databases"
Dim DA As New SqlDataAdapter(strSQL, conn)
Dim DS As New DataSet
DA.Fill(DS, "dblist")

For i = 0 To ds.Tables(0).Rows.Count - 1
cmbdb.items.add(ds.Tables(0).Rows(i).Item(0).Tostring())
Next


这篇关于如何调用或查看sql server 2000的所有数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆