Maged Algaafary Maged Algaafary - 1 year ago 101 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
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 Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download