C# 从 Microsoft 数据库中获取字符串数组

C# get String array out of Microsoft Data Base

我正在尝试在我的 WinForm 程序中生成一个 TreeView。 我有一个非常大的数据库。我需要从整个数据库中获取列名,然后在 TreeView

中显示

这可能吗?

谢谢

贾尼克

哪个"Microsoft Data Base"?如果你谈论 MS SQL 服务器,你应该看看 SELECT * FROM INFORMATION_SCHEMA.COLUMNS 你可以加载到你的代码中并填充任何你想要的...

如果你在画树时遇到问题,那么你可以使用这个(作为例子)

//Draw TreeView in design or initialize as below
            var treeView = new TreeView
            {
               CheckBoxes = true, // optional, if you need the set true
               Width = 300,       //according you requirement
               Height = 0,
               ForeColor = Color.FromArgb(255, 20, 185, 213),
               Font = new Font("Segoe UI", 9.0f, FontStyle.Bold),
               BorderStyle = BorderStyle.None
            };
            Controls.Add(treeView);
            //set location etc.
            var list = _localDb.GetBrowseNodeParents();
            foreach (var node in list)
            {                    
                treeView.Nodes.Add(node.NodeId, node.NodeName).Tag = node.NodeUrl;
                treeView.Nodes[node.NodeId].ForeColor = Color.Black;
            }