나는 프로그래밍 할 때 새로운데, 사용자가 MySQL의 다양한 데이터 테이블을 선택, 삽입, 업데이트 및 삭제할 수있는 기본 VB.NET 응용 프로그램에서 작업하고있다.vb.net mysql combobox show tables
내가 겪고있는 문제는 하나의 특정 데이터베이스에서 모든 테이블 이름으로 콤보 박스를 채워야하므로 사용자가 작업 할 데이터베이스 테이블을 선택할 수 있습니다. 내 코드는 효과가있을 것이라고 생각했지만 앱을 실행할 때 빈 컴보 박스 만 얻었습니다.
내 코드에 무엇이 잘못 되었습니까?
미리 감사드립니다.
코드 :
Private Sub TableList_SelectedIndexChanged(sender As System.Object, e As System.EventArgs) Handles TableList.SelectedIndexChanged
Try
command = New MySqlCommand
dt = New DataTable
adapter = New MySqlDataAdapter
If (conn.State = ConnectionState.Closed) Then
setConnection()
End If
command.Connection = conn
command.CommandText = "SHOW TABLES"
adapter.SelectCommand = command
reader = command.ExecuteReader
'adapter.Fill(dt)
dt.Load(reader)
TableList.DataSource = dt
TableList.DisplayMember = "Tables_in_sampledata" 'What is displayed
TableList.ValueMember = "Tables_in_sampledata" 'The ID of the row
Catch ex As MySqlException
MessageBox.Show("Error1: " & ex.Message)
Finally
reader.Close()
conn.Close()
End Try
End Sub
을 사용하여 어떤 오류의 당신이받을 수 있나요? –