我在尝试使用 VB.NET 从 MySQL 数据库中读取数据时遇到问题,我收到的错误消息是“ArgumentExcpetion 未处理”
此外,读数应返回“F”,因为这是分配在桌子上特定位置的值。
Imports MySql.Data.MySqlClient
Public Class Form1
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Application.Exit()
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim query As String = "SELECT DO FROM klein WHERE COMMAND='DELETE'"
Dim connStr As String = "server=" & TextBox1.Text & ";" _
& "user id=" & TextBox2.Text & ";" _
& "password=" & TextBox3.Text & ";" _
& "database=hidro201_liberato"
Dim connection As New MySqlConnection(connStr)
Dim cmd As New MySqlCommand(query, connection)
connection.Open()
Dim reader As MySqlDataReader
reader = cmd.ExecuteReader()
While reader.Read()
TextBox4.Text = (reader.GetChar(1)) '<- **problem is here**
End While
End Sub
End Class