Click to See Complete Forum and Search --> : Dataset does not store special characters
cesark
Feb 16th, 2004, 10:11 AM
Hi !
(I use VB.NET)
I have a dataset that is populated manually through the data entered in a form, but special characters like (ñ, à, á, ï,etc,..) it seems are not stored in the dataset, simply are omitted. For example if you enter in a text field ‘Cañon’ the dataset shows ‘Caon’ when you retrieves the data from the dataset.
Somebody can explain me why this happens and how can I solve it?
Thank you,
Cesar
hellswraith
Feb 16th, 2004, 10:17 AM
Just a thought, may not work, but try HttpEncoding the string before it gets to the page.
strMyString = HttpUtility.HttpEncode(strMyString)
or something like that....
cesark
Feb 16th, 2004, 10:27 AM
Ok, but I don' t know where I have to write it.
The code in the page 1 that stores the data:
Sub myData()
Dim ds as new DataSet
Dim dt as new DataTable
dt.columns.add("Mail")
Dim row As DataRow
row = dt.NewRow
row.Item("Mail") = mail.Text
dt.Rows.Add(row)
ds.tables.add(dt)
Session("UserData") = ds
End Sub
The code in the page 2 that retrieves the data:
Dim UserDS As Data.DataSet = Session("UserData")
control.Text = UserDS.Tables(0).rows(0).Item("Mail")
hellswraith
Feb 16th, 2004, 02:24 PM
Try right here:
row.Item("Mail") = HtmlEncode(mail.Text)
Or right here:
control.Text = HtmlEncode(UserDS.Tables(0).rows(0).Item("Mail"))
cesark
Feb 17th, 2004, 02:49 AM
Thank you but this is not correct. It must have another solution :confused:
cesark
Feb 17th, 2004, 05:28 PM
Oh yes, I'm sorry, your code runs, I had something wrong. Anyway it has the same result, don' t store the special characters.
But I have seen that if I erase the (CODEPAGE="1252") from the <%@Page Language="VB" CODEPAGE="1252"%>, then store the special characters, but I need this 'codepage' in the page because the '.js' validations, if I erase this codepage the alert messages of the '.js' validations also omit the special characters like (ñ, Ñ, é, è, ï,...).
Do you know another solution?
Thank you,
Cesar
hellswraith
Feb 17th, 2004, 05:34 PM
Sorry, special characters are out of my area of comfort....lol.
That was the only thing I could think of.
Could you do a Response.Write(mail.Text) statement to be sure that the special characters are being brought back?
If they are, then maybe there is a setting of the dataset that will allow it?
Wish I could help more, I just don't know it.
cesark
Feb 18th, 2004, 02:54 AM
I have done one 'response.write..' and it does the same.
In fact aren' t special characters, are characters that are used in Spanish language and other occidental languages.
My main problem is the alert messages of the '.js' validations, a cause of that I need to put <%@ Page Language="VB" CODEPAGE="1252"%>, because If I don' t put this 'codepage' the alert messages don' t allow these characers (ñ, Ñ, é, è, ü,..) of the Spanish language. Without the (codepage="1252") the application runs normally with all the occidental characters included (ñ, Ñ, é, è, ü, etc..).
It doesn' t matter if you don' t know this subject, anyway thank you for your aid !
Cesar
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.