Solved

copy file into listbox

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

910 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

26 Experts available now in Live!

Get 1:1 Help Now