User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Visual Basic 4 / 5 / 6 section within the Software Development category of DaniWeb, a massive community of 397,592 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,861 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Visual Basic 4 / 5 / 6 advertiser:
Views: 3236 | Replies: 6
Reply
Join Date: Oct 2006
Posts: 3
Reputation: bpmccall is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 1
bpmccall bpmccall is offline Offline
Newbie Poster

Bind ListBox to ADODB.Recordset

  #1  
Oct 17th, 2006
I am new to the whole concept of "data binding". What I am trying to do seems very simple, but I don't know where to start. I have a database with an ODBC System DSN and I can connect to it with an ADODB.Connection object. I can also create an ADODB.Recordset object and traverse/manipulate the records contained in it. What I am unable to do is bind a listbox to this recordset. I know I could simply create code to traverse both the listbox and the recordset to copy recordset data to the listbox and remove listbox entries that are not in the recordset, but this is not a trivial task. Clearing the listbox and repopulating is easy enough, but doing this will reset the selected list item every time, and this is unacceptable. Any suggestions?

By the way, I am using VB 6.0
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jul 2008
Posts: 4
Reputation: arun_kumar112 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
arun_kumar112 arun_kumar112 is offline Offline
Newbie Poster

Re: Bind ListBox to ADODB.Recordset

  #2  
Jul 21st, 2008
I want to add item in list box but through sql query how can i do
Reply With Quote  
Join Date: Nov 2006
Posts: 709
Reputation: QVeen72 is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 95
QVeen72's Avatar
QVeen72 QVeen72 is offline Offline
Master Poster

Re: Bind ListBox to ADODB.Recordset

  #3  
Jul 21st, 2008
Hi,

Use DBListBox, Set datasource to an ADODB.recordset.. and bind

Regards
Veena
Reply With Quote  
Join Date: Jul 2008
Posts: 4
Reputation: vishvaabala is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
vishvaabala vishvaabala is offline Offline
Newbie Poster

Re: Bind ListBox to ADODB.Recordset

  #4  
Jul 21st, 2008
Set Rs = Nothing
Rs.open " Select * From Table Where Cond ...",Con,adOpenStatic
if Rs.Recordcount > 0 then
   rs.movefirst
  do while not rs.eof
    list1.Additem rs.fields("Field1")
    rs.movenext
  loop
end if
Last edited by Tekmaven : Jul 21st, 2008 at 2:29 pm. Reason: Code tags
Reply With Quote  
Join Date: Jul 2008
Posts: 4
Reputation: arun_kumar112 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
arun_kumar112 arun_kumar112 is offline Offline
Newbie Poster

Re: Bind ListBox to ADODB.Recordset

  #5  
Jul 21st, 2008
Thanks,

I have to create list of item which are selected in list box like
" a,b,c,d,e,f " How can I do ? it can be in a string .
Reply With Quote  
Join Date: Jul 2008
Posts: 4
Reputation: arun_kumar112 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
arun_kumar112 arun_kumar112 is offline Offline
Newbie Poster

Re: Bind ListBox to ADODB.Recordset

  #6  
Jul 21st, 2008
I have to create list of item which are selected in list box like
" a,b,c,d,e,f " How can I do ? it can be in a string .
Reply With Quote  
Join Date: Jul 2008
Posts: 4
Reputation: vishvaabala is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
vishvaabala vishvaabala is offline Offline
Newbie Poster

Re: Bind ListBox to ADODB.Recordset

  #7  
34 Days Ago
Hi Arun

This is Bala. Sorry I Cant Understand ur Qry. Give me the Prper.

Bye
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb Visual Basic 4 / 5 / 6 Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the Visual Basic 4 / 5 / 6 Forum

All times are GMT -4. The time now is 6:07 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC