我在 MS Access 中有一个表,其中有一个名为 NameC 的列(使用 ODBC 连接到 MS Access)
我希望将以下查询的结果保存在 txtField
Dim query = "SELECT NameC FROM Table WHERE ClientID = " & Integer.Parse(clientID)
如何在 VB.NET 中做到这一点?
我有一个txtNameC.Text
领域
我目前正在查看一些示例代码,他们这样做了:
Dim _consultationTable As DataTable
Public Sub Load()
Dim query = "SELECT * FROM Table WHERE ClientID = " & Integer.Parse(clientID)
Me._consultationTable = DatabaseFunctions.GetDataTable(query)
dvgInfo.Rows.Clear()
For Each dtRow In Me._consultationTable.Rows
dvgInfo.Rows.Add()
dvgInfo.Rows.Add(dvgInfo.RowCount-1).Cells("ColClientID").Value = dtRow("ClientId").ToString()
Next
但我不想填写表格 我只想将查询结果放入文本框中 我该怎么做?
我想做这样的事情,但只是返回一个值并将其保存到文本框中
Protected Sub BindData()
strSQL = "SELECT * FROM customer"
Dim dtReader As OdbcDataReader
objCmd = New OdbcCommand(strSQL, objConn)
dtReader = objCmd.ExecuteReader()
'*** BindData to GridView ***'
myGridView.DataSource = dtReader
myGridView.DataBind()
dtReader.Close()
dtReader = Nothing
End Sub
Protected Sub BindData()
strSQL = "SELECT SpecificValue FROM customer where x = y..."
Dim dtReader As OdbcDataReader
objCmd = New OdbcCommand(strSQL, objConn)
dtReader = objCmd.ExecuteReader()
'*** BindData to GridView ***'
myGridView.DataSource = dtReader
myGridView.DataBind()
dtReader.Close()
dtReader = Nothing
End Sub