How to retriev data frm DB in datacombo

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Sep 2008
Posts: 22
Reputation: asmit1987 is an unknown quantity at this point 
Solved Threads: 0
asmit1987 asmit1987 is offline Offline
Newbie Poster

How to retriev data frm DB in datacombo

 
0
  #1
Sep 25th, 2008
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
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 2,641
Reputation: Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light 
Solved Threads: 245
Jx_Man's Avatar
Jx_Man Jx_Man is offline Offline
Posting Maven

Re: How to retriev data frm DB in datacombo

 
0
  #2
Sep 25th, 2008
  1. Private Sub ReadData()
  2. Dim i As Integer
  3.  
  4. con.ConnectionString = ("Provider = Microsoft.JET.OLEDB.4.0;Data Source= D:\Only Me\Authors.mdb")
  5. Try
  6.  
  7. cmdOle = con.CreateCommand
  8. cmdOle.CommandText = "SELECT * FROM Authors "
  9. da.SelectCommand = cmdOle
  10. da.Fill(dsOle, "Authors")
  11. dtOle = dsOle.Tables("Authors")
  12. For i = 0 To dtOle.Rows.Count - 1
  13. cmbAuthor.Items.Add(dtOle.Rows(i).Item(1))
  14. Next
  15.  
  16. Catch ex As Exception
  17. MsgBox("Error: " & ex.Source & ": " & ex.Message, MsgBoxStyle.OKOnly, "Koneksi Error !!")
  18. End Try
  19. con.Close()
  20. 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))
Never tried = Never Know
So, Please do something before post your thread.
* PM Asking will be ignored *
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 22
Reputation: asmit1987 is an unknown quantity at this point 
Solved Threads: 0
asmit1987 asmit1987 is offline Offline
Newbie Poster

Re: How to retriev data frm DB in datacombo

 
0
  #3
Sep 28th, 2008
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.....
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 2,641
Reputation: Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light 
Solved Threads: 245
Jx_Man's Avatar
Jx_Man Jx_Man is offline Offline
Posting Maven

Re: How to retriev data frm DB in datacombo

 
0
  #4
Sep 29th, 2008
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"))
Last edited by Jx_Man; Sep 29th, 2008 at 12:14 am.
Never tried = Never Know
So, Please do something before post your thread.
* PM Asking will be ignored *
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the VB.NET Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC