Issue with &

vbnethelp

New member
Joined
Apr 28, 2010
Messages
2
Programming Experience
3-5
HI !
On dropdown load event, I am using following select statement
select REPLACE('test test',' ',"& #160;")

which replaces blank spaces with " & #160;"
but when i populate the drop down , vb is converting "&" with "&"

Can any one explain me why is it doing so.
Here is my complete code

Protected Sub drpMunicipality_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles drpMunicipality.Load

Dim connectionString As String = globalUtil.getConnectionString()
Dim conn As New OracleConnection
Dim cmd As New OracleCommand
Dim ds1 As New DataSet
Dim adapter As New OracleDataAdapter

Dim strsql As String

conn.ConnectionString = connectionString
conn.Open()
strsql = " select REPLACE('test test',' ','& #160;') as MUN_NM from dual"
Response.Write("strsql" & strsql)

cmd = New OracleCommand(strsql, conn)
adapter.SelectCommand = cmd

adapter.Fill(ds1)
Me.drpMunicipality.DataSource = ds1.Tables(0).DefaultView
drpMunicipality.DataTextField = "MUN_NM"

drpMunicipality.DataBind()

conn.Close()
conn.Dispose()
End Sub
End Class
 
You need to escape the & with another & so it's: strsql = " select REPLACE('test test',' ','&& #160;') as MUN_NM from dual"
 
You need to escape the & with another & so it's: strsql = " select REPLACE('test test',' ','&& #160;') as MUN_NM from dual"

Thanks for your reply.

Nope it doesn't help I tried it, every occurrence of "&" is replaced by " & #160;".

Here I am trying to replace the space in the text received from Database with
"& #160;" so that I can preserve the space while displaying it in browser.
 
I'm not sure then, does Oracle have an escape char? I've never used Oracle for the backend so I don't know these things off hand, but I'm sure a google search would answer the question pretty quickly
 
Oracle isnt interested in this at all. You can selecy '&' from Oracle all day, and you'll always get '&' out of it
It is VB.NET ASP that will be converting the bare & in your code, to &
 
Back
Top