Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27358

Query access DB by column name and fill listBox with column info

$
0
0
Hello everyone,

First I want to query an Access DB by column name (on a specific table): comparing a TextBox with the column name (therefor the below sql code)
Second, fill a listBox with the information that this column has.

Connection is already made.

On main form code I have:

Code:

   
Private Sub txtDisp_Leave(sender As Object, e As EventArgs) Handles txtDisp.Leave
        Dim strSql As String = "SELECT column_name FROM Model WHERE ='" & txtDisp.Text & "'"

//HERE I SHOULD FILL A COMBOBOX WITH THE COLUMN NAME

I found that this code should return a List of column names:

Code:

   

Public Function nombreColumnas() As List(Of String)
        Dim table As String = "Model"
        Dim restrictions As String() = New String() {Nothing, Nothing, table , Nothing}
        Dim dataTable As DataTable = conexion.GetSchema("Columns", restrictions)
        Dim returnList As List(Of String) = New List(Of String)

        For Each dataRow As DataRow In dataTable.Rows
            returnList.Add(dataRow("column_name"))
        Next
        Return returnList
    End Function

How can I change it to return only the column name that is equal to txtDisp.text?

Viewing all articles
Browse latest Browse all 27358

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>