我想要返回我的查询=" show database" 然后这是我的代码
dim conn as conn.connectionstring = Myconnection
dim Mydb as new Mysql.data.mysqlclient.mysqlcommand(myquery,conn)
conn.open
textbox2.text = convert.tostring(mydb.excutescalar())
我的输出是:
答案 0 :(得分:0)
现在我找到了一种方法
以下代码
Dim myQuery As String = "show databases"
TextBox1.Text = "localhost"
constring = "server=" & TextBox1.Text & ";" _
& "uid=root;" _
& "pwd=admin;" _
& "database=mysql;"
Try
conn.ConnectionString = constring
Dim myDb As New MySql.Data.MySqlClient.MySqlCommand(myQuery, conn)
conn.Open()
ComboBox1.Text = "select database"
'myDb.Connection.Open()
'TextBox2.Text = TextBox2.Text + Convert.ToString(myDb.ExecuteScalar())
Dim myReader As MySql.Data.MySqlClient.MySqlDataReader = myDb.ExecuteReader()
Try
While myReader.Read
ComboBox1.Items.Add(myReader.GetString(0))
End While
Finally
myReader.Close()
conn.Close()
End Try
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try