我正在尝试弄清楚如何使用 Visual Basic 查询访问数据库,但我正在寻找有关其实际工作原理的一些解释。
我感到困惑的是,我陈述了一个命令SELECT * FROM PI
(PI
作为表格),但在其正下方,我说的是那个TextBox1.Text = theDataTable.Rows(0).Item(1)
。
我只是想知道为什么我有一个查询命令,然后是一个单独的命令,该命令将转到指定的行和项目......非常感谢任何帮助!
Imports System.Data.OleDb
Public Class Form1
Dim theConnectionString As New OleDbConnection
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
txtSQL.Clear()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
theConnectionString.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Marc Wilson\Documents\FiddleFuckDB.accdb"
theConnectionString.Open()
Dim theDataSet As New DataSet
Dim theDataTable As New DataTable
theDataSet.Tables.Add(theDataTable)
Dim theDataAdapter As New OleDbDataAdapter
theDataAdapter = New OleDbDataAdapter("SELECT * FROM PI", theConnectionString)
theDataAdapter.Fill(theDataTable)
TextBox1.Text = theDataTable.Rows(0).Item(1)
theConnectionString.Close()
End Sub
End Class