Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Web App - Double spaces problem

Posted on 2004-11-02
12
Medium Priority
?
223 Views
Last Modified: 2010-04-23
Hi,

     I have a web app with a combo box that fills from a database column.  In the database, some items have two spaces in places, i.e. the one I'm dealing with:

Tape Measure--Power Lock

where -- indicates 2 spaces.  So of course in the webform dropdownlistbox, the two spaces are truncated to one as for all web stuff.  Now when I look in the database from the chosen value in the dropdownlistbox, the two don't match up.  Is there any simple way to do this before I have to write some program to wax all double spaces in the database?

JP
0
Comment
Question by:gleznov
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
  • 3
  • +1
12 Comments
 
LVL 20

Expert Comment

by:ihenry
ID: 12473558
Yes, simply replace each space with this " " (without quotes).
0
 

Author Comment

by:gleznov
ID: 12473762
But that'll take an algorithm on every record right?  Couldn't that cause performance issues?  Or is there a simple command to change " " into " "?

JP
0
 
LVL 8

Expert Comment

by:toddhd
ID: 12473954
Haven't tested it, but I assume that in OnDataBind(), you could simply run something like:
currentitem=Replace(currentitem," ","  ")

0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 8

Expert Comment

by:toddhd
ID: 12473970
This page shows a snippet of using OnDataBind and a ComboBox
http://www.codeproject.com/cs/miscctrl/ComboView.asp
0
 
LVL 6

Expert Comment

by:slyckboy
ID: 12478255
I think it would be less of a strain on resources if you were just to add a pk to the query used to fill the cbobox.

then assign the pk to the datavaluefield of the combobox and the name of the other field to the datatextfield.  Then when you compare to the database compare the datavaluefield to the pk.

If this is not clear let me know and i will elaborate further.
0
 

Author Comment

by:gleznov
ID: 12485977
pk?  primary key?  I'm not understanding how to do all that?

JP
0
 
LVL 6

Accepted Solution

by:
slyckboy earned 800 total points
ID: 12486215
Yes a primary key.  Generally a table on a database has a field that acts as a unique identifier.  So you would use that instead of the name field.  For example...
(all my db stuff is oracle, use whatever is appropriate)

Dim strConnect As String = _
      "Data Source=datasource;" & _
      "User ID=" & username & ";" & _
      "Password=" & pwd & ";"

Dim cn As OracleConnection
Dim cmd As OracleCommand
cn = New OracleConnection(strConnect)
cn.Open()

cmd = New OracleCommand("select id,name from your_table",cn))
cbo.datasource = cmd.executereader(commandbehavior.closeconnection)
cbo.DataValueField = "id"     'this line would associate with the id or primary key
cbo.DataTextField = "name"   'this line would associate with the name field or your "Tape Measure--Power Lock" this is what would be displayed in the drop down list

cbo.DataBind()

dim intValue as integer
dim strText as string

intValue = cbo.selecteditem.value  '  This will give you the id (Primary Key) of the selected item in the dropdown list
strText = cbo.selecteditem.text      ' This will give you the name ("Tape Measure--Power Lock") of the selected item in the drop down list

so you would use intValue to compare with the database since it will be the same spaces or not.  If you need me to go further and create a dataset to compare values against let me know.
0
 
LVL 8

Expert Comment

by:toddhd
ID: 12486320
slyckboy - I'm not understanding what you are saying either, in regards to the problem that is. The problem was that the spaces between the words Tape Measure and Power Lock are showing up as once space, not two, which HTML is apt to do. (Note that there are NOT two dashes (--) between the words, he only used that as an example to show where the spaces were).

What you showed above seems to be an example of how to load the combobox from a database, but it doesn't seem to address the problem, which is replacing the spaces with two  
0
 
LVL 8

Assisted Solution

by:toddhd
toddhd earned 200 total points
ID: 12486359
Gleznov, is it reasonable for you to write a very short app that simply reads each description column in the database, does a Replace() as noted above, and then saves the value back to the database? It would take only minutes to write such a thing, and might save you a lot of frustration in the meantime.
0
 
LVL 6

Expert Comment

by:slyckboy
ID: 12486386
Maybe i am misunderstanding, but wasn't the reason he was trying to add the two spaces was to compare the selected item with the database.  And since html takes the space out they weren't jiving.  So instead of worrying about the extra spaces and trying to find where every double space is supposed to be and replacing them for every row, every time the page is rendered, it would be less resource intensive to compare something that does not change.  If i am misunderstanding let me know.
0
 
LVL 8

Expert Comment

by:toddhd
ID: 12486423
Yup, ok - I see your point now. And you are correct then - going with an index or pk would alleviate the problem.
0
 

Author Comment

by:gleznov
ID: 12522943
Thanks guys!

JP
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

610 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