请..如何在ToolstripLabel1中显示我的数据库名称
使用此代码,数据库的名称将显示在TextBox1 ..但当我尝试编写ToolstripLabel1而不是TextBox1时,我收到错误。
我的代码:
Private Sub Get_DataBase_Name()
Db_Connection()
InfoGetDataName = New DataTable
Using AdapterGetDataName As New SqlDataAdapter(" SELECT DB_NAME() AS DataBaseName ", Con)
AdapterGetDataName.Fill(InfoGetDataName)
TextBox1.DataBindings.Add("Text", InfoGetDataName, "DataBaseName")
End Using
End Sub
在Form1中加载:Get_DataBase_Name()
提前感谢您的帮助.Cordially.AABIDINE
答案 0 :(得分:0)
你不需要这个
TextBox1.DataBindings.Add("Text", InfoGetDataName, "DataBaseName")
只需用
替换它ToolStripLabel1.Text = "DataBaseName"
另外,因为我认为您想要将查询结果的值显示到toolstriplabel1,您的查询将导致1行与一个单元格 试试这段代码。
ToolStripLabel1.Text = (dtbale.Rows(0)).ItemArray(0).ToString