嗨,大家好我试图使用SQL将数据从MS Access 2007显示到文本框。我没有错误,程序运行正常,但它没有在文本框中显示数据。
我在设计名称EmpNoTextbox
下检查了我的文本框属性,另一个文本框是EmpLnameTextbox
。我对哪里出错了感到困惑。
以下是我的代码
Imports System.Data.OleDb
Public Class SearchForm
Dim con As New OleDbConnection
Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles Statdd.SelectedIndexChanged
End Sub
Private Sub showItems()
con.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0; Data Source=C:\Database\Company_db.accdb"
con.Open()
Dim ds As New DataSet
Dim dt As New DataTable
ds.Tables.Add(dt)
Dim da As New OleDbDataAdapter
da = New OleDbDataAdapter("SELECT * FROM tbl_empinfo", con)
da.Fill(dt)
EmpNoTextbox.Text = dt.Rows(0).Item(0)
EmpLnameTextbox.Text = dt.Rows(0).Item(1)
con.Close()
End Sub
Private Sub SearchButton_Click(sender As Object, e As EventArgs) Handles SearchButton.Click
End Sub
Private Sub CloseButton_Click(sender As Object, e As EventArgs) Handles CloseButton.Click
Me.Close()
Form1.Close()
End Sub
Private Sub MainMenuButton_Click(sender As Object, e As EventArgs) Handles MainMenuButton.Click
Me.Close()
Form1.Show()
End Sub
End Class