如何从数据库中读取瑞典语/特殊字符并将其正确显示在ASP.NET页中 [英] How to read Swedish/special characters from a database and display it in ASP.NET page correctly

查看:81
本文介绍了如何从数据库中读取瑞典语/特殊字符并将其正确显示在ASP.NET页中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在尝试从数据库中读取瑞典语字符,并将其显示在我的ASP.NET页上.但是,无法从数据库中正确读取数据.
例如.

Hi,

I am trying to read Swedish characters from the database and display them on my ASP.NET page. However the data is not read correctly from the Database.
Eg.

Café.


被读取为


is read as

Café.


ö读为ö

我正在使用3层体系结构,下面是我用来获取数据集中的值的代码:


ö is read as ö

I am using 3 tier architecture and below is the code I used to get the values in a dataset:

Public Function GetDataSetProc(ByVal strSql As String) As DataSet
       Return GetDataSetProc(strSql, DirectCast(Nothing, OleDbParameter()))
   End Function


   Public Function GetDataSetProc(ByVal strSql As String, ByVal arProcParams As OleDbParameter()) As DataSet
       Dim dataSet As New DataSet()
       Try
           OpenDBConnection()
           dataCom.CommandText = strSql
           dataCom.CommandTimeout = 1000
           dataCom.Parameters.Clear()
           dataAdp.SelectCommand = dataCom

           If arProcParams IsNot Nothing Then
               For Each param As OleDbParameter In arProcParams
                   dataCom.Parameters.Add(param)
               Next
           End If
           dataAdp.Fill(DataSet)
           dataCon.Close()

       Catch ex As Exception
           WriteToLog(ex.Message.ToString())
       End Try
       Return DataSet

   End Function



请帮助我以正确的方式从数据库中读取数据!
在此先感谢:)



KIndly help me read the data from the database in a correct way !!!!!

Thanks in Advance :)

推荐答案

改用支持Unicode的文本SQL数据类型,例如ncharnvarcharntext charvarchartext的值.

请参阅: http://msdn.microsoft.com/en-us /library/ms191200%28v=sql.105%29.aspx [
Use text SQL data types supporting Unicode, such as nchar, nvarchar, and ntext, instead of char, varchar, and text.

Please see: http://msdn.microsoft.com/en-us/library/ms191200%28v=sql.105%29.aspx[^].

—SA


这篇关于如何从数据库中读取瑞典语/特殊字符并将其正确显示在ASP.NET页中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆