Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB Databases Basics
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
VB Databases Basics Beginning-level VB coding questions specific to using VB with databases. Issues not specific to database use will be redirected to other forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB Databases Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 29th, 2007, 03:03 PM
Registered User
 
Join Date: Jul 2007
Location: , , .
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default Making ComboBox to display the List from DB table

Hi Guys,

Please, please can anyone help. I seem to be stuck with a problem, I have created tables in SQL Server 2005 Express with the following definitions:

Customer
    [Customer ID]
    [NAME] nvarchar(100),
    [CONTACT_NAME] nvarchar(60),
    [CONTACT_1] nvarchar(100),
    [CONTACT_2] nvarchar(50),
    [CITY_TOWN] nvarchar(70),
    [PROVINCE] varchar(50),
    [COUNTRY] varchar(100)

Country
  [COUNTRY NAME]
  [City]

I have created a user-interface with Visual Basic Express 2005. So what steps do I use to link a CountryComboBox on the user-interface form to the table - Country [COUNTRY NAME]? So that the CountryComboBox can display the list of countries from the - database table - Country for the user. Thanks a lot.


Reply With Quote
  #2 (permalink)  
Old August 1st, 2007, 05:55 PM
Registered User
 
Join Date: Jul 2007
Location: , , .
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I do not know if this will work for what you want, but this is what I use with vb6 to open a database and load a listbox.

Code:
Private Sub Command1_Click()
Dim cn As New ADODB.Connection


    List1.Clear


    With cn 'database
   
        cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " & App.Path & "\DataBase Name.mdb;"

    End With

 
Set rs = New ADODB.Recordset 'as we did with the connection
rs.Open "databaseName", cn, adOpenKeyset, adCmdTable 'opening the recordset 
      
      
      With List1 'this will add to a list bpx called List1

      Do While Not rs.EOF       
      .AddItem rs.Fields("database record")'Change the name of the field here to the one you want to show
      .Refresh
      rs.MoveNext
      Loop

    End With

  rs.close  ' tidy up things
  set rs = nothing 
 
end sub     
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Data Bind ComboBox to display the List Bjay Pro VB Databases 0 July 29th, 2007 02:57 PM
Populating master table with list from list table sburgess Access 7 September 1st, 2006 06:03 AM
Making changes to DB on hosting server w/ VS.NET ltdanp21 SQL Server 2000 5 June 18th, 2004 01:28 PM
Making changes to DB on hosting server w/ VS.NET ltdanp21 VS.NET 2002/2003 1 June 15th, 2004 03:55 PM
making a db field link on a page doranaz Classic ASP Databases 0 December 19th, 2003 01:13 PM



All times are GMT -4. The time now is 08:48 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.