连接oracle读取数据
时间:2021-07-01 10:21:17
帮助过:3人阅读
class LoadData
{
/// <summary>
///
/// </summary>
/// <returns></returns>
public static string GetCunliangfang(
string idNo)
{
string oraclePath = Application.StartupPath +
@"\Lib";
Environment.SetEnvironmentVariable("PATH", oraclePath, EnvironmentVariableTarget.Process);
Environment.SetEnvironmentVariable("NLS_LANG",
"SIMPLIFIED CHINESE_CHINA.ZHS16GBK", EnvironmentVariableTarget.Process);
string rtn =
string.Empty;
//string connString = "Provider=OraOLEDB.Oracle.1;User ID=tax;Password=tax;Data Source=(DESCRIPTION = (ADDRESS_LIST= (ADDRESS = (PROTOCOL = TCP)(HOST = ****)(PORT = *****))) (CONNECT_DATA = (SERVICE_NAME = orcl)))";
string connString =
"Persist Security Info=True;User ID=tax;Password=tax;Unicode=True;Data Source=(DESCRIPTION =(ADDRESS_LIST =(ADDRESS = (PROTOCOL = TCP)(HOST =140.28.21.14)(PORT = 1521)))(CONNECT_DATA =(SERVICE_NAME = orcl)));";
OracleConnection conn =
new OracleConnection(connString);
conn.Open();
string sql =
string.Format(
"select * from FDCJY_JYFCXX_HZ", idNo);
// WHERE ID_SNO=‘{0}‘
OracleCommand cmd =
new OracleCommand(sql, conn);
OracleDataReader dr =
cmd.ExecuteReader();
if (dr.Read())
{
ArrayList arr =
new ArrayList();
arr.Add(dr["OC_CQRZJLX"]);
//卖方证件类型代码
arr.Add(dr[
"OC_CQRLXDH"]);
//联系电话
arr.Add(dr[
"OC_CQRGJ"]);
//卖方国籍代码
arr.Add(dr[
"OC_CQRLXDZ"]);
//卖方地址
arr.Add(dr["OC_MFXM"]);
//"买方姓名
arr.Add(dr[
"OC_MFZJLX"]);
//"买方证件类型
arr.Add(dr[
"OC_MFZJHM"]);
//证件号码
arr.Add(dr[
"OC_MFGJ"]);
//国籍代码
arr.Add(dr[
"OC_MFLXDH"]);
//联系电话
arr.Add(dr[
"OC_MFLXDZ"]);
//联系地址
//房屋信息
arr.Add(dr[
"DT_HTQDRQ"].ToString());
//合同签订日期
arr.Add(dr[
"OC_QXDM"]);
//行政区划
arr.Add(dr[
"OC_JDXZ"]);
//街道乡镇
arr.Add(dr[
"OC_FWZL"]);
//房屋所属地,有默认
arr.Add(dr[
"OC_FCZH"]);
//房产证号
arr.Add(dr[
"OC_HTZJ"].ToString());
//合同金额
arr.Add(dr[
"OC_FCLX"]);
//房产类型
arr.Add(dr[
"OC_FCZH"]);
//房屋幢号
arr.Add(dr[
"OC_SZLC"]);
//楼层
arr.Add(dr[
"OC_SCJYFS"]);
//上次取得房屋方式
////arr.Add(dr["OC_HTZJ"]);//交易价格--临时不用
arr.Add(dr[
"DT_SCJYSJ"].ToString());
//上次交易时间
arr.Add(dr[
"oc_fwtc"]);
//上次房屋取得成本
arr.Add(dr[
"OC_JYLX"]);
//交易类型
arr.Add(dr[
"OC_BZ"]);
//备注
rtn =
string.Join(
",", (
string[])arr.ToArray(
typeof(
string)));
}
conn.Close();
cmd.Dispose();
return rtn;
}
}
连接oracle读取数据
标签: