熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> Oracle >> 正文

SERVER數據轉換ORACLE問題(1)

2022-06-13   來源: Oracle 

  大家做系統更新或者升級都可能要觸及到數據的轉換
對於ORACLE中的數據轉換可以用寫存儲過程來放之游標將你要的數據一條一條的轉換
而對於SERVER雖然你可以將它轉換到ORACLE中(升級的方式)但有問題你會發現有的表是不可以直接轉換的!
所以我就用代碼控制直接轉換!也是一種比較容易控制容易寫的方法!
首先你要在程序中建立連接(server的)

  string strCon=workstation id=XJ;packet size=;user id=sa;data source=automap\automap;persist security info=True;initial catalog=bgxtrmt;password=sa;
string strTxt = SELECT tworder_code stru_b layer_b area_ub area_b east south west north area_sb densy_b grean_b park park_bike other_areagrean_bsp_build_p FROM bgxtpab_;
SqlConnection SqlCon = new SqlConnection(strCon);
SqlCommand SqlCmd = new SqlCommand(strTxtSqlCon);
SqlConOpen();
然後將你要讀的數據用dataReaderreader方法讀進來!

  SqlDataReader SqlDR = SqlCmdExecuteReader(CommandBehaviorCloseConnection);

  while(SqlDRRead())
{
try
{
OracleConOpen();
Bgxtpab_ bg = new Bgxtpab_();
//Doc d = new Doc();
//int i = ;
bgTworder_Code = SqlDRGetString()Trim();
bgStru_B = SqlDRIsDBNull()?:SqlDRGetString()Trim();
bgLayer_B = SqlDRIsDBNull()?:SqlDRGetInt();
bgArea_UB = SqlDRIsDBNull()?:SqlDRGetString();
bgArea_B = SqlDRIsDBNull()?:SqlDRGetString();
bgEast_B = SqlDRIsDBNull()?:SqlDRGetString()Trim();
bgSouth_B = SqlDRIsDBNull()?:SqlDRGetString()Trim();
bgWest_B = SqlDRIsDBNull()?:SqlDRGetString()Trim();
bgNorth_B = SqlDRIsDBNull()?:SqlDRGetString()Trim();

  //bgLayer_BD = SqlDRIsDBNull(++i)?F:SqlDRGetInt(i);
bgArea_SB = SqlDRIsDBNull()?:SqlDRGetString();
bgDensy_B = SqlDRIsDBNull()?:SqlDRGetString();
bgPark = SqlDRIsDBNull()?F:SqlDRGetFloat();
bgPark_Bike = SqlDRIsDBNull()?F:SqlDRGetFloat();
bgOTher_Area = SqlDRIsDBNull()?F:SqlDRGetFloat();
bgGrean_B = SqlDRIsDBNull()?F:SqlDRGetFloat();
bgSp_build_P = SqlDRIsDBNull()?:SqlDRGetString();
這樣你就獲得了你要的數據還要提到的是!你必須為你想讀的表寫個數據表的類!
using System;

  namespace ProjectBulid
{
/// <summary>
/// Bgxtpab_工程數據表
/// </summary>
public class Bgxtpab_
{
string tworder_code;
//string project_b;
string densy_b;
string stru_b;
int layer_b;
string area_ub;
string area_b;
string usage_b;
string east;
string south;
string west;
string north;
string area_sb;

  float grean_b;
float park;
float park_bike;
// decimal other_area_b;
string sp_build_p;
float other_area;

  public Bgxtpab_()
{
tworder_code = ;
//project_b= ;
stru_b = ;
layer_b = ;
area_ub = ;
area_b = ;
usage_b = ;
east = ;
south= ;
west = ;
north = ;
//layer_db = ;
area_sb = ;
densy_b = ;
grean_b = F;
park = F;
park_bike = F;
sp_build_p = ;
other_area = F;

  }
public string Tworder_Code
{
get
{
return tworder_code;
}
set
{
tworder_code = value;
}
}
public string Densy_B
{
get
{
return densy_b;
}
set
{
densy_b = value;
}
}
// public int Project_B
// {
// get
// {
// return project_b;
// }
// set
// {
// project_b = value;
// }
// }
public string Stru_B
{
get
{
return stru_b;
}
set
{
stru_b = value;
}
}
public int Layer_B
{
get
{
return layer_b;
}
set
{
layer_b = value;
}
}
public string Area_UB
{
get
{
return area_ub;
}
set
{
area_ub = value;
}
}
public string Area_B
{
get
{
return area_b;
}
set
{
area_b = value;
}
}
public string Usage_B
{
get
{
return usage_b;
}
set
{
usage_b = value;
}
}
public string East_B
{
get
{
return east;
}
set
{
east = value;
}
}
public string South_B
{
get
{
return south;
}
set
{
south = value;
}
}
public string West_B
{
get
{
return west;
}
set
{
west = value;
}
}
public string North_B
{
get
{
return north;
}
set
{
north = value;
}
}
// public int Layer_BD
// {
// get
// {
// return layer_db;
// }
// set
// {
// layer_db = value;
// }
// }
public string Area_SB
{
get
{
return area_sb;
}
set
{
area_sb = value;
}
}
public float Grean_B
{
get
{
return grean_b;
}
set
{
grean_b = value;
}
}
public float Park
{
get
{
return park;
}
set
{
park = value;
}
}
public float Park_Bike
{
get
{
return park_bike;
}
set
{
park_bike = value;
}

  }
public string Sp_build_P
{
get
{
return sp_build_p;
}
set
{
sp_build_p = value;
}
}
public float OTher_Area
{
get
{
return other_area;
}
set
{
other_area = value;
}
}

  }
}


From:http://tw.wingwit.com/Article/program/Oracle/201311/18757.html
    推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.