Click here to Skip to main content
15,888,527 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
any one please help

VB
 Try



            'Dim Cmd As OleDb.OleDbCommand
            Dim Con As OleDb.OleDbConnection
            Dim Sql As String = Nothing
            'Dim Reader As OleDb.OleDbDataReader
            Dim ds As New DataSet()
            Dim adapter As New OleDbDataAdapter()


            Con = New OleDb.OleDbConnection(DBpath)

            Sql = "SELECT Users.* from Users where LoginID=" & "'" & TextBox1.Text & "'"

            'Cmd = New OleDb.OleDbCommand(Sql, Con)
            adapter.SelectCommand = New OleDbCommand(Sql, Con)
            Con.Open()

            adapter.Fill(ds, "Users")
            Dim item As DataTable = ds.Tables(0)
            DataGridView1.DataSource = ds.Tables("Users")

            Console.WriteLine("Table name: {0}", item.TableName)
            Console.WriteLine("Its columns are:")

            
            For Each col As DataColumn In item.Columns
                If col.ColumnName.Substring(col.ColumnName.Length - 3) = "Upd" Then
-----HERE I GOT TO FIND THE FIELDS I WANT BUT NEED TO PICK the value of that field_______
                    'If row(col.ColumnName).Item.ToString = "yes" Then
                    
                        Console.WriteLine("{0}" & vbTab & "{1}", col.ColumnName, col.DataType)                    End If
                End If
            Next
           






            Con.Close()






        Catch ex As Exception
            MsgBox(ex.Message)
        End Try


    End Sub


I cant retrieve value of that field when it gets to field that has UPD as name?
Posted
Updated 26-Nov-14 5:37am
v2

1 solution

Do the column names begin with "Upd"? Or end with "Upd"? You are currently looking at the end.

"A string that is equivalent to the substring that begins at startIndex in this instance"



That's rather inefficient, but how about col.ColumnName.StartsWith( "Upd" ) or col.ColumnName.EndsWith( "Upd" ) ?
 
Share this answer
 
v2
Comments
mrukr 26-Nov-14 12:19pm    
test1Upd
test2Upd
exam3Upd
(all of these columns are check box)
If each box are check then its yes or true,..

So how do I get it to read the fields that have UPD and also if its check or not?
mrukr 26-Nov-14 12:23pm    
For Each col As DataColumn In item.Columns
If col.ColumnName.EndsWith("Upd") Then >>>>>THIS WORKS


>>>then if I want to use that first column with UPD and get its data???how do I do this If item.Rows(0).Item(4) = True Then

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900