Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to format this string

Status
Not open for further replies.

andypower

Programmer
Aug 10, 2004
23
0
0
IN
i m developing application in vb 6 and sql server 7.
in my Customertable there r almost 700-800 records. i want to add all these records in list box. i use getstring method of ado to get that string in that i pass vbcrlf and also chr(13) function to seperate row but in list box instead of new line it shows square box so plz help me regarding that.
StrSQL = ""
StrSQL = "select Accountname from customertable AccountName like'" & Trim(txt.text) & "%'"
RsShow.Open StrSQL, Conn, adOpenForwardOnly
strsql=""
StrSQL = RsShow.GetString(adClipString, -1, ",", vbcrlf, "{NULL}")
lstLedgerName.AddItem StrSQL
or is there any way to add records to list without using loop.
 
You can try binding the recordset to the list box via a data control and the listbox .datasource property.

Looks like you are missing the 'Where' keyword in your SQL. I assume that it is only a typo.

BTW, are there any other filters you can add? 700 items in a list box can make it difficult/time consuming for a user to find a single item.

zemp
 
You can also display recordset fields in a DataList control without having to use a Data control. Add the Microsoft DataList Controls 6.0 to your project, place a DataList control on your form and use this code to populate the list:

Set DataList1.DataSource = RsShow
Set DataList1.RowSource = RsShow
DataList1.ListField = "AccountName"
DataList1.Refresh

This should do what you want.

P.S.: You can of course change the control name to whatever you need it to be - the DataList control behaves like the "regular" list control, so you can replace the existing one and probably not have to change any code, except for the code to fill the list.




I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top