以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- [求助]服务器端获取SQL有哪些数据库 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=158897) |
-- 作者:blsu33 -- 发布时间:2020/12/6 17:41:00 -- [求助]服务器端获取SQL有哪些数据库 老师,如何用代码获取对应的SQL数据库上面有哪些数据库,想要将SQL上面的数据库做一个下拉列表。 |
-- 作者:blsu33 -- 发布时间:2020/12/6 18:23:00 -- Dim cmd1 As New SQLCommand cmd1.C cmd1.CommandText = "select * f rom sys.databases " Dim str As New Dictionary(Of String,object) str=cmd1.ExecuteValues For Each st As String In str.Keys MessageBox.Show(st) Next 这样写不对
|
-- 作者:rjh4078 -- 发布时间:2020/12/6 20:03:00 -- Dim cmd1 As New SQLCommand cmd1.Conne cti cmd1.CommandText = "select * f rom sys.databases " Dim dt As DataTable dt=cmd1.ExecuteReader For Each st As String In dt.GetValues("name") output.Show(st) Next
|
-- 作者:blsu33 -- 发布时间:2020/12/6 21:29:00 -- 谢谢 Dim cmd1 As New SQLCommand cmd1.C cmd1.CommandText = "select name f rom sys.databases where name not In (\'master\',\'msdb\',\'tempdb\',\'model\') " Dim DT As DataTable=CMD1.ExecuteReader Dim CMB As WinForm.ComboBox = e.Form.Controls("ComboBox1") CMB.ComboList=DT.GetComboListString("name") |