读取Oracle成功,但除了Number类型的数据可以读取到大部分外,其余一概显示为空白,无任何数据。找了整天都搞不定,请各位路过的朋友帮个忙解决,非常感谢。
如图:
下面是代码:
app.config
Code
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
</configSections>
<connectionStrings>
<add name="FileOracle" connectionString="Data Source=File;Persist Security Info=True;User ID=Fileuser;Password=123"
providerName="System.Data.OracleClient" />
</connectionStrings>
<appSettings>
<add key="FileDB" value="FileOracle" />
<add key="FileConnString" value="Data Source=File;Persist Security Info=True;User ID=Fileuser;Password=123" />
</appSettings>
</configuration>
DBCL.cs
Code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.Common;
using System.Data.OracleClient;
using System.Configuration;
namespace FileManager.Ocl
{
public class DBCL
{
private string _DBName;
public DBCL()
{
//
//
//
}
public string DBName
{
get { return _DBName; }
set { _DBName = value; }
}
/// <summary>
/// 获取 DataSet
/// </summary>
public DataSet GetDS(string SQL)
{
string strConnection = DBName;
OracleConnection oraConn = new OracleConnection(strConnection);
OracleDataAdapter oda = new OracleDataAdapter(SQL, oraConn);
DataSet ds = new DataSet();
try
{
oda.Fill(ds);
}
catch(Exception ee)
{
throw ee;
}
return ds;
}
}
}
Form1.cs
Code
using FileManager.Ocl;
using System.Configuration;
private void bt_Debug_Click(object sender, EventArgs e)
{
dbcl = new DBCL();
DataSet ds = new DataSet();
int intCountRows = 0;
int intCountColumns = 0;
dbcl.DBName = ConfigurationSettings.AppSettings["FileConnString"];
string sql = "select * from FileInformation";
ds = dbcl.GetDS(sql);
intCountRows = ds.Tables[0].Rows.Count;
for (int i = 0; i < intCountRows; i++)
{
this.tb_debug.Text += ds.Tables[0].Rows[i]["File_Name"].ToString() + "\r\n";//tb_debug=TextBox
}
}