I want to retrieve data frm my DB in a datacombo what event nd property shud i use plz help me with the single line code to retrieve data

Private Sub ReadData()
        Dim i As Integer

        con.ConnectionString = ("Provider = Microsoft.JET.OLEDB.4.0;Data Source= D:\Only Me\Authors.mdb")
        Try

            cmdOle = con.CreateCommand
            cmdOle.CommandText = "SELECT * FROM Authors "
            da.SelectCommand = cmdOle
            da.Fill(dsOle, "Authors")
            dtOle = dsOle.Tables("Authors")
            For i = 0 To dtOle.Rows.Count - 1
                cmbAuthor.Items.Add(dtOle.Rows(i).Item(1))
            Next

        Catch ex As Exception
            MsgBox("Error: " & ex.Source & ": " & ex.Message, MsgBoxStyle.OKOnly, "Koneksi Error !!")
        End Try
        con.Close()
End Sub

in looping function ReadData will fill cmbAuthor with 2nd column from table author (.item(1), index start from 0). cmbAuthor.Items.Add(dtOle.Rows(i).Item(1))

if i want to store data from datacombo of a particular field of the table of a database the cmbAuthor u mentioned and the code cmbAuthor.Items.Add(dtOle.Rows(i).Item(1)) will it be sufficient bcoz no where else u mentioned the field name.....

I was told u in previous post, I said the index of item means index of column on your table.but you can change with :
cmbAuthor.Items.Add(dtOle.Rows(i).Item("ColumnName"))

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.