日期:2014-05-17 浏览次数:20443 次
Dim b As Byte() = System.Text.Encoding.GetEncoding("gbk").GetBytes(strSql)
strSql = System.Text.Encoding.GetEncoding("cp850").GetString(b)
'必须将sql查询语句转为cp850编码,否则无法语句中无法使用中文
Dim SybaseConn As New AseConnection("Data Source='0.0.0.0';UID='nitty';PWD='sa';Database='abc';")
Dim SybaseCom As New AseCommand(strSql, SybaseConn)
'数据库连接字符串
Dim SybaseDA As New AseDataAdapter(SybaseCom)
Dim Ds As New DataSet
SybaseConn.Open()
SybaseDA.Fill(Ds)
'正常的填充DATASET
GridView1.DataSource = Ds.Tables(0)
GridView1.DataBind()
'绑定
SybaseConn.Open()
SybaseDA.Fill(DS)
DT.Columns.Add("编号", GetType(String))
DT.Columns.Add("付款单位", GetType(String))
DT.Columns.Add("金额", GetType(Double))
DT.Columns.Add("备注", GetType(String))
DT.Columns.Add("付款银行", GetType(String))
DT.Columns.Add("付款账号", GetType(String))
DT.Columns.Add("时间", GetType(Date))
For i As Integer = 1 To DS.Tables(0).Rows.Count
Dim NDR As DataRow = DT.NewRow
For c As Integer = 0 To 6
NDR(c) = GetEncoding("gbk").GetString(GetEncoding("cp850").GetBytes(DS.Tables(0).Rows(i - 1).Item(c)))
Next
DT.Rows.Add(NDR)
Next
GridView1.DataSource = DT
GridView1.DataBind()