We help IT Professionals succeed at work.

aspx space(??) problem

stephenz43
stephenz43 asked
on
Medium Priority
691 Views
Last Modified: 2012-05-06
I have a aspx app. I'm trying to do the following :
sqlStatement = "SELECT fdgrp_desc  + '                               '  + fdgrp_cd as results from fd_group order by fdgrp_desc  "

The spacing seems to be ignored. I dont get it. It works perfectly in vb.net against the db.

any help by help would be appreciated
Steve
       
Comment
Watch Question

Do you mean that you try to show the sqlStatement itself on the ASPX page? If you are trying to do that, the space will be truncated, that's how HTML works. But internally in the memory, the variable sqlStatement still contains as many space as you have put in there.

Author

Commented:
Im executing the sqlStatement against a data reader. The trunacation is the problem. I need those spaces .....

Try to change each space to ' ' (without the quote)
If you are pulling it back like this to delineate, try something a little different.

SELECT fdgrp_cd + ',' + fdgrp_desc  as results from fd_group order by fdgrp_desc

And then when you get your result back from SQL, in your app do a little string manipulation

string[] stemp = dbr["results"].ToString().Split(",".ToCharArray(), 2);

this will give you
stemp[0]=fd_group
stemp[1]=description

If that is indeed what you are trying to do. It's very flexible this way, and the Split(x,2) makes sure to only split these into two items, so if your description has commas, you are safe.

HTH.
You mean when you try to show the results in the ASPX page you dont get the space displayed between those 2 colums. You will need to replace that with   to get the space working in HTML like this
while(sqlReader.Read())
{
  Response.Write(sqlReader[0].ToString().Replace(" ", "&bnsp;");
}
 
or on VB.net
 
 
 
While sqlReader.Read()
   Response.Write(sqlReader(0).ToString().Replace(" ", "&bnsp;"))
End While

Open in new window

Sorry one closing bracket missing in c#
while(sqlReader.Read())
{
  Response.Write(sqlReader[0].ToString().Replace(" ", "&bnsp;"));
}

Open in new window

Sorry this one i mistyped &bnsp; for  
while(sqlReader.Read())
{
  Response.Write(sqlReader[0].ToString().Replace(" ", " "));
}
 
or on VB.net
 
 
 
While sqlReader.Read()
   Response.Write(sqlReader(0).ToString().Replace(" ", " "))
End While

Open in new window

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Commented:
Philipjonathan is right. put ' ' in place of each space. Other wise if u take space then it will get truncated.
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.