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!

Creating CSV to pass to a stored procedure

Status
Not open for further replies.

summitx

Programmer
Jan 20, 2006
7
0
0
CA
this is mostly a question to those of you with plenty of experience.

I have a form with a listbox(listbox2) that is populated based on single or multi select items from another listbox(listbox1).

It seems the thought online is the build a UDF, creating a table parssing the values into a single paramater that is accepted by the executed stored procedure.

Currently I am achieving the same results by passing the sql statement (I know bandwidth, SQL statements are a no no), but in a high bandwidth environment would this be quicker? Here is how I am currently achieving my results. I am pretty sure I could achievethe same thing using the in operator but this does work and It is a loop requiring no user input besides selecting the items from listbox1

For Each varitem In listbox1.ItemsSelected '
strwhere = "(dbo.table.field = "
stritem = "'" & Me.listbox1.ItemData(varitem) & "'"
If x < i Then
strsp = strsp & strwhere & strposition & ") OR "
Else
strsp= strsp & strwhere & strposition & ")"
End If
x = x + 1

Next

strsql = " SELECT * " & _
" FROM table " & _
" WHERE " & strsp

listbox2.rowsource = strsql


Your thoughts?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top