code to select columns stsrting with same letter

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • padhminiatluri
    New Member
    • Jun 2007
    • 1

    code to select columns stsrting with same letter

    please tell the code to select all the columns starting with same letter in asp.net using vb actually my query is working in sql server but i want to know the syntax which works in .net using vb
  • shweta123
    Recognized Expert Contributor
    • Nov 2006
    • 692

    #2
    Hi,

    You can try this code,

    con.ConnectionS tring = "Provider=SQLOL EDB.1;Persist Security Info=True;User ID=sa;password= ;Initial Catalog=Pubs;Da ta Source=."
    con.Open()

    da = New OleDbDataAdapte r("Select * from Authors", con)

    da.Fill(ds)
    Dim col(10) As DataColumn
    Dim i As Integer = 0
    For Each c As DataColumn In ds.Tables(0).Co lumns
    If UCase(c.ColumnN ame).StartsWith ("A") Then

    col(i) = c

    i = i + 1
    End If
    Next
    con.Close()


    Is it the same thing you are looking for?

    Comment

    Working...