Solved

copy file into listbox

Posted on 2002-03-22
3
128 Views
Last Modified: 2010-05-02
how can i copy the record (e.g. Street Name field) in the database into the listbox ?
0
Comment
Question by:tabing16
  • 2
3 Comments
 

Expert Comment

by:carloss
ID: 6890419
Here's a sample:

Dim rsList as ADODB.Recordset

Set rsList = new ADODB.Recordset

With rsList
.Open "SELECT CompanyName FROM Customers", "PROVIDER=SQLOLEDB;Integrated Security=SSPI;DATABASE=Northwind;SERVER=(local)", adOpenForwardOnly, adLockReadOnly, adCmdText

While Not(.EOF)
lstNames.AddItem .Fields(0).Value
.MoveNext
Wend
End With
0
 

Author Comment

by:tabing16
ID: 6890560
I'm sorry, let me correct my question...i had succeeded to load the database field (Street Name field) into the listbox, i  did the random function to the field using SQL statement, but the problem is it was sequential random, what i want is a random result that is different everytime I start the application, and one more problem is i could not put randomize keyword inside the SQL statement, is there anyway to do random function outside the SQL statement but affect the result ot Street Name and put the random result into the listbox ?
0
 

Accepted Solution

by:
carloss earned 30 total points
ID: 6892183
Add an order by clause and use the information_schema views to get a column name.  The view has an ordinal position column which is numeric.  Use this value when selecting a column.  Since its numeric, you can use the RAND() function to get a random numeric value, and select the column name based on a comparison of the random number and the column's ordinal position.
0

Featured Post

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Visual Studio 2005 text editor 10 38
MsgBox 4 61
VB 6 error 5 in windows 10 but not in XP 7 56
Set email body to html using vbscript 6 41
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

778 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question