breaking a string

A

amatuer

I usesd this to display info on a page:
<% While not rstMain.eof %>
<tr>
<td><font size="-1"><%= rstMain("Datum") %></font></td>
<!-- <td><font size="-1"><b>Client no</b></font></td> -->
<td><font size="-1"><%= rstMain("Act") %></font></td>
<td><font size="-1"><%= rstMain("Item") %></font></td>
<td><font size="-1"><input type="checkbox" name="Inv" id="Inv"
value="<%= rstMain("TR_ID") %>"></font></td>
</tr>
<% rstMain.movenext
Wend%>

on the next page i want the data from the checkbox.it comes as a
string,numerics concatanated with a ","

i want to query according to this checkbox n tried this code:

For i=1 to (len(request.form("Inv")))
If left(request.form("Inv"),i) = "," Then
count = count + 1
End If
Next

'For i=1 to count do
'var1=instr(request.form("Inv"),",")

'sql="SELECT * From V_Transaksie Where ID=" &
left(request.form("Inv"),var1-1)
'set rstMain = CreateObject("ADODB.Recordset")
'rstMain.Open sql, "Provider=SQLOLEDB.1;Persist Security
Info=False;User ID=sa;password=admin@sql;Initial Catalog=GIS;Data
Source=172.16.4.180",1,4


All above ASP.Please help
 
M

Mike Brind

amatuer said:
I usesd this to display info on a page:
<% While not rstMain.eof %>
<tr>
<td><font size="-1"><%= rstMain("Datum") %></font></td>
<!-- <td><font size="-1"><b>Client no</b></font></td> -->
<td><font size="-1"><%= rstMain("Act") %></font></td>
<td><font size="-1"><%= rstMain("Item") %></font></td>
<td><font size="-1"><input type="checkbox" name="Inv" id="Inv"
value="<%= rstMain("TR_ID") %>"></font></td>
</tr>
<% rstMain.movenext
Wend%>

on the next page i want the data from the checkbox.it comes as a
string,numerics concatanated with a ","

i want to query according to this checkbox n tried this code:

For i=1 to (len(request.form("Inv")))
If left(request.form("Inv"),i) = "," Then
count = count + 1
End If
Next

'For i=1 to count do
'var1=instr(request.form("Inv"),",")

'sql="SELECT * From V_Transaksie Where ID=" &
left(request.form("Inv"),var1-1)
'set rstMain = CreateObject("ADODB.Recordset")
'rstMain.Open sql, "Provider=SQLOLEDB.1;Persist Security
Info=False;User ID=sa;password=admin@sql;Initial Catalog=GIS;Data
Source=172.16.4.180",1,4


All above ASP.Please help

You need to use the split() function:

checkboxes = split(Request.Form("Inv"),",")

This returns a one-dimensional array called checkboxes, with the first
index being zero. So to iterate through it:

For i = 0 to Ubound(checkboxes)
...do some stuff with the current checkbox - which is checkboxes(i)
Next
 
A

amatuer

Thanx i gt the var to split the numerics
bt nw i need to use these numerics in a query:

eg:
sql="SELECT * From V_Transaksie Where ID=" & 22 & "Or ID=" & 23
I need a way to find out hw many commas in the original var and hw many
"or" statements to add
 
M

Mike Brind

amatuer said:
Thanx i gt the var to split the numerics
bt nw i need to use these numerics in a query:

eg:
sql="SELECT * From V_Transaksie Where ID=" & 22 & "Or ID=" & 23
I need a way to find out hw many commas in the original var and hw many
"or" statements to add

No you don't. Use the SQL IN clause.

sql="SELECT * From V_Transaksie WHERE ID IN(" & Request.Form("Inv") &
")"
 
M

Mike Brind

amatuer said:
thanx Mike, i displayed the query and it looks like it'l work

No problem. By the way, if you ever did need to know how many values
there are in the array created by split(), Ubound(array) +1 will tell
you.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,140
Latest member
SweetcalmCBDreview
Top