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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

string delimiter

Status
Not open for further replies.

boux123

Technical User
Mar 20, 2007
16
CA
Hi,

As explained in the previous thread, I am create a webpage that displays server info from a database. What servers the user selects will be added to a new table created in the sql database. However, when more than one server is selected, these servernames are inserted into the table as a string.

For ex:

server1 and server 2 are selected.

In the table the two servers are displayed like this

server1/, server2/

In order to solve this problem I attemped split the names.

While Not oRs.EOF

serverString = oRs("serverName")
MyArray = Split(serverString, "/,")



'tempID = Trim(oRs("serverName"))
Response.write "<br /><font size='2'>Server:&nbsp;&nbsp;<b>" & oRs("serverName") & "</b>&nbsp;&nbsp;&nbsp;Server Location:&nbsp;&nbsp;<b>" & oRs("serverLocation") & "</b>"
Response.write "<br /><i>Select This Server:</i>&nbsp;&nbsp;<input type='checkbox' name='server' id='serverSelect' value=" & tempID & "/></font><br />"
oRs.MoveNext
Wend

However, this does not work. The only thing that is shown now in the SQL database is: /,

Thx
 
Try this for debugging:
Code:
Do While Not oRs.EOF 
  serverString = oRs("serverName") & ""
  if serverString <> "" then
    MyArray = Split(serverString, "/,")

    For iCount = 0 to uBound(MyArray)
      Response.Write cStr(iCount) & " - " & MyArray(iCount) & "<BR>" & vbCrLf
    Next 
  else
    Response.Write "Data field was empty. <BR>" & vbCrLf
  end if 

  oRs.MoveNext
Loop

Also be sure that the real values are actually stored in the database field as expected.
 
Hey,

I tried you code. However, when the servers are submitted into the database, it still shows these servers as: server1/, server/.

Thx
 
I am not clear on the goal you wish to achieve.

The purpose of the debug code posted above is to convert a string from one format to another.

Input is this format: [tt]server1/,server2/,server3[/tt]

Output is:[tt]
server1
server2
server3
[/tt]

I was under the impression that the issue is not how the items are STORED in the database, but rather how to control the DISPLAY of items stored in that particular format.

Please clarify.
 
In the database:

The servers that are selected as displayed like this:

server1/, server2,

However, in the database, I want the servers to be displayed in this format:

server1, server2

Basically i want the "/" character to be taken out.
 
Maybe, before inserting the values, you could use the Replace() function to replace all slashes for an empty string.

Ex:<%
TheString = "server1/,server2/,server3"
TheString = Replace(TheString, "/", "")
Response.Write TheString
%>

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top