Solved

copy file into listbox

Posted on 2002-03-22
3
126 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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…

743 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now