我用vs2008做了一个vb程序,是从数据库oracle读取数据
我用vs2008做了一个vb程序,是从数据库oracle读取数据,然后将读取的数据赋值给textbox,但是在textbox显示的是几个正方形的乱码,究竟是怎么回事呢,麻烦各位大侠帮忙咯
数据库服务器的注册表:HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE\HOME0
NLS_LANG 键值: AMERICAN_AMERICA.US7ASCII
我主要是想通过在vb里面进行转换编码,然后让中文能够正常读出,有什么办法呢,代码如下
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim oradb As String = "Data Source=(DESCRIPTION=(ADDRESS_LIST=" _
+ "(ADDRESS=(PROTOCOL=TCP)(HOST=172.130.2.2)(PORT=1521)))" _
+ "(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=ORCL)));" _
+ "User Id=system;Password=manager;"
Try
Dim conn As New OracleConnection(oradb)
conn.Open()
Dim cmd As New OracleCommand
cmd.Connection = conn
cmd.CommandText = "Select name from clinic_master where job_id='2323212'"
cmd.CommandType = CommandType.Text
Dim dr As OracleDataReader = cmd.ExecuteReader()
While dr.Read()
TextBox2.Text = dr.Item("name")
End While
dr.Dispose()
cmd.Dispose()
conn.Dispose()
Catch ex As Exception
MessageBox.Show(ex.Message.ToString())
Finally
End Try
End Sub
[解决办法]
dr.Item("name").ToString()