Maged Algaafary Maged Algaafary - 27 days ago 19
Vb.net Question

how to use select (col array())from table

Public Overloads Function SETData(Table As Tables, Col() As String) As Statuez
Dim DD As New DataSet, State As New Statuez
Try
DD = R.Dset(Table, "Select **col()** from " & Table.TName & " where username='" & Table.User & "'")
DG.DataSource = DD.Tables(0)
State.Done = True
Catch ex As Exception
State.Done = False
State.Message = ex.Message
End Try
Return State
End Function


*** Col() As String is an array holds the names of columns needed

Is there any way to select column array with out typing every member of the array ?

Ric Ric
Answer

You can do this:

Dim result As String = String.Join(",", Col)

then use the result in the SELECT statement.

Aside from this, perhaps you should look at parameterizing your statements as it is vulnerable to sql injection.