private static void load2DParcels(float y0, float x0, Oracle.ManagedDataAccess.Client.OracleCommand command) { string result = ""; command.CommandText = "SELECT " + "b.bfsid, " + "c.sequence, " + "p.point.SDO_POINT.y, " + "p.point.SDO_POINT.x " + "FROM tile_2D_SU suidx, la_spatialunit su, boundary b, corner c, la_point p " + "WHERE suidx.roundy = " + (int)y0 + " AND suidx.roundx = " + (int)x0 + " AND " + "suidx.suid = su.suid AND " + "su.suid = b.suid AND " + "b.bfsid = c.boundaryid AND " + "c.pid = p.pid " + "GROUP BY b.bfsid, c.sequence, p.point.SDO_POINT.y, p.point.SDO_POINT.x " + "ORDER BY b.bfsid, c.sequence"; Oracle.ManagedDataAccess.Client.OracleDataReader dataReader = command.ExecuteReader(); int j = 0; while (dataReader.Read()) // && j++ < 10) { for (int i = 0; i < dataReader.FieldCount; i++) { result += dataReader[i].ToString() + ";"; } result += "n"; } dataReader.Close(); Console.WriteLine(result); }
int ManagedOracleClient() { Oracle.ManagedDataAccess.Client.OracleConnectionStringBuilder connBuilder = new Oracle.ManagedDataAccess.Client.OracleConnectionStringBuilder(); connBuilder.DataSource = txtDataSource.Text.Trim(); connBuilder.UserID = txtUserId.Text.Trim(); connBuilder.Password = txtPwd.Text.Trim(); connBuilder.ConnectionTimeout = 300; connBuilder.ConnectionLifeTime = 10; connBuilder.MinPoolSize = 0; int rows = 0; using (Oracle.ManagedDataAccess.Client.OracleConnection conn = new Oracle.ManagedDataAccess.Client.OracleConnection(connBuilder.ConnectionString)) { Oracle.ManagedDataAccess.Client.OracleCommand cmd = conn.CreateCommand(); cmd.CommandText = txtSql.Text.Trim(); cmd.CommandTimeout = 300; conn.Open(); using (Oracle.ManagedDataAccess.Client.OracleDataReader dr = cmd.ExecuteReader()) { while (dr.Read()) { object[] objs = new object[500]; dr.GetValues(objs); rows++; } } return(rows); } }
public void counttt(out String erreur, out Int32 ss, out Boolean exist) { erreur = null; ss = 0; exist = false; rsql = "select count(1) from AJJ"; cnx.select(rsql, out erreur, out dr); if (erreur == null) { if (dr.HasRows == true) { exist = true; while (dr.Read()) { ss = Convert.ToInt32(dr[0]); } } dr.Close(); } }
private static void load3DParcels(float y0, float x0, Oracle.ManagedDataAccess.Client.OracleCommand command) { string result = ""; command.CommandText = "SELECT " + "su.suid, " //0 + "su.cislo_par, " //1 + "b.bfid, " //2 + "b.direction, " //3 + "c.sequence, " //4 + "p.point.SDO_POINT.y, " //5 + "p.point.SDO_POINT.x, " //6 + "c.elevation " + //7 "FROM tile_3D_SU suidx, la_spatialunit su, boundary3D b, corner c, la_point p " + "WHERE suidx.roundy = " + (int)y0 + " AND suidx.roundx = " + (int)x0 + " AND " + "suidx.suid = su.suid AND " + "su.suid = b.suid AND " + "b.bfid = c.boundaryid AND " + "c.pid = p.pid " + "GROUP BY su.suid, su.cislo_par, b.bfid, b.direction, c.sequence, p.point.SDO_POINT.y, p.point.SDO_POINT.x, c.elevation " + "ORDER BY su.suid, b.bfid, c.sequence"; //Oracle.ManagedDataAccess.Types. //ListDictionaryInternal Oracle.ManagedDataAccess.Client.OracleDataReader dataReader = command.ExecuteReader(); //STRUCT strukturaBodu = (oracle.sql.STRUCT)dataReader.getObject(3); //JGeometry geometrieBodu = JGeometry.load(strukturaBodu); int j = 0; while (dataReader.Read()) // && j++ < 10) { for (int i = 0; i < dataReader.FieldCount; i++) { result += dataReader[i].ToString() + ";"; } result += "n"; } dataReader.Close(); Console.WriteLine(result); }
internal static void GetData(int num, bool readClob, bool readBlob) { //using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["connstr"].ConnectionString)) //{ // DataTable table = new DataTable(); // SqlDataAdapter adp = new SqlDataAdapter(string.Format("select top {0} * from TEMP_TestTKK0719-- order by newid()", num), conn); // adp.Fill(table); //} switch (ConfigurationManager.AppSettings["dbtype"].ToUpper().Trim()) { case "SYSTEM.DATA.ORACLECLIENT": using (OracleConnection conn = new OracleConnection(ConfigurationManager.ConnectionStrings["connstr"].ConnectionString)) { OracleCommand cmd = conn.CreateCommand(); conn.Open(); cmd.CommandText = string.Format("select 1 from user_tables t where t.table_name = upper('TEMP_TestTKK0719')"); object tableInited = cmd.ExecuteScalar(); if (tableInited == null || tableInited == DBNull.Value) { cmd.CommandText = @"CREATE TABLE TEMP_TestTKK0719( code varchar2(50) NOT NULL, name varchar2(100) NULL, age int NULL, birthday timestamp NULL, salary decimal(10, 2) NULL, summary varchar2(1000) NULL, remark clob NULL, extends blob NULL, created timestamp, CONSTRAINT PK__TEMP_TestTKK0719 PRIMARY KEY (code) )"; cmd.ExecuteNonQuery(); cmd.CommandText = "create index idx_TEMP_TestTKK0719_Name on TEMP_TestTKK0719(name)"; cmd.ExecuteNonQuery(); cmd.CommandText = "create index idx_TEMP_TestTKK0719_age on TEMP_TestTKK0719(age)"; cmd.ExecuteNonQuery(); cmd.CommandText = "create index idx_TEMP_TestTKK0719_birthday on TEMP_TestTKK0719(birthday)"; cmd.ExecuteNonQuery(); } conn.Close(); cmd.CommandText = string.Format("select code, name, age, birthday, salary, summary, created {1} {2} from TEMP_TestTKK0719 where rownum <= {0}", num, (readClob ? ", remark" : string.Empty), (readBlob ? ", extends" : string.Empty)); conn.Open(); using (OracleDataReader dr = cmd.ExecuteReader()) { while (dr.Read()) { object[] objs = new object[500]; dr.GetValues(objs); } } conn.Close(); } break; case "ODP.NET": using (IDbConnection conn = ODPClientFactory.CreateConnection()) { conn.ConnectionString = ConfigurationManager.ConnectionStrings["connstr"].ConnectionString; IDbCommand cmd = conn.CreateCommand(); conn.Open(); cmd.CommandText = string.Format("select 1 from user_tables t where t.table_name = upper('TEMP_TestTKK0719')"); object tableInited = cmd.ExecuteScalar(); if (tableInited == null || tableInited == DBNull.Value) { cmd.CommandText = @"CREATE TABLE TEMP_TestTKK0719( code varchar2(50) NOT NULL, name varchar2(100) NULL, age int NULL, birthday timestamp NULL, salary decimal(10, 2) NULL, summary varchar2(1000) NULL, remark clob NULL, extends blob NULL, created timestamp, CONSTRAINT PK__TEMP_TestTKK0719 PRIMARY KEY (code) )"; cmd.ExecuteNonQuery(); cmd.CommandText = "create index idx_TEMP_TestTKK0719_Name on TEMP_TestTKK0719(name)"; cmd.ExecuteNonQuery(); cmd.CommandText = "create index idx_TEMP_TestTKK0719_age on TEMP_TestTKK0719(age)"; cmd.ExecuteNonQuery(); cmd.CommandText = "create index idx_TEMP_TestTKK0719_birthday on TEMP_TestTKK0719(birthday)"; cmd.ExecuteNonQuery(); } conn.Close(); cmd.CommandText = string.Format("select code, name, age, birthday, salary, summary, created {1} {2} from TEMP_TestTKK0719 where rownum <= {0}", num, (readClob ? ", remark" : string.Empty), (readBlob ? ", extends" : string.Empty)); conn.Open(); using (IDataReader dr = cmd.ExecuteReader()) { while (dr.Read()) { object[] objs = new object[500]; dr.GetValues(objs); } } conn.Close(); } break; case "ODAC": using (ManagedOralceConnection conn = new ManagedOralceConnection(ConfigurationManager.ConnectionStrings["connstr"].ConnectionString)) { ManagedOracleCommand cmd = conn.CreateCommand(); conn.Open(); cmd.CommandText = string.Format("select 1 from user_tables t where t.table_name = upper('TEMP_TestTKK0719')"); object tableInited = cmd.ExecuteScalar(); if (tableInited == null || tableInited == DBNull.Value) { cmd.CommandText = @"CREATE TABLE TEMP_TestTKK0719( code varchar2(50) NOT NULL, name varchar2(100) NULL, age int NULL, birthday timestamp NULL, salary decimal(10, 2) NULL, summary varchar2(1000) NULL, remark clob NULL, extends blob NULL, created timestamp, CONSTRAINT PK__TEMP_TestTKK0719 PRIMARY KEY (code) )"; cmd.ExecuteNonQuery(); cmd.CommandText = "create index idx_TEMP_TestTKK0719_Name on TEMP_TestTKK0719(name)"; cmd.ExecuteNonQuery(); cmd.CommandText = "create index idx_TEMP_TestTKK0719_age on TEMP_TestTKK0719(age)"; cmd.ExecuteNonQuery(); cmd.CommandText = "create index idx_TEMP_TestTKK0719_birthday on TEMP_TestTKK0719(birthday)"; cmd.ExecuteNonQuery(); } conn.Close(); cmd.CommandText = string.Format("select code, name, age, birthday, salary, summary, created {1} {2} from TEMP_TestTKK0719 where rownum <= {0}", num, (readClob ? ", remark" : string.Empty), (readBlob ? ", extends" : string.Empty)); conn.Open(); using (ManagedOracleDataReader dr = cmd.ExecuteReader()) { while (dr.Read()) { object[] objs = new object[500]; dr.GetValues(objs); } } conn.Close(); } break; default: using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["connstr"].ConnectionString)) { SqlCommand cmd = conn.CreateCommand(); conn.Open(); cmd.CommandText = string.Format("select 1 from sys.tables t where t.name = 'TEMP_TestTKK0719'"); object tableInited = cmd.ExecuteScalar(); if (tableInited == null || tableInited == DBNull.Value) { cmd.CommandText = @"CREATE TABLE TEMP_TestTKK0719( code varchar(50) NOT NULL, name varchar(100) NULL, age int NULL, birthday datetime NULL, salary decimal(10, 2) NULL, summary nvarchar(1000) NULL, remark varchar(max) NULL, extends varbinary(max) NULL, created datetime, CONSTRAINT PK__TEMP_TestTKK0719 PRIMARY KEY (code) )"; cmd.ExecuteNonQuery(); cmd.CommandText = "create index idx_TEMP_TestTKK0719_Name on TEMP_TestTKK0719(name)"; cmd.ExecuteNonQuery(); cmd.CommandText = "create index idx_TEMP_TestTKK0719_age on TEMP_TestTKK0719(age)"; cmd.ExecuteNonQuery(); cmd.CommandText = "create index idx_TEMP_TestTKK0719_birthday on TEMP_TestTKK0719(birthday)"; cmd.ExecuteNonQuery(); } conn.Close(); cmd.CommandText = string.Format("select top {0} code, name, age, birthday, salary, summary, created {1} {2} from TEMP_TestTKK0719", num, (readClob ? ", remark" : string.Empty), (readBlob ? ", extends" : string.Empty)); conn.Open(); using (SqlDataReader dr = cmd.ExecuteReader()) { while (dr.Read()) { object[] objs = new object[500]; dr.GetValues(objs); } } conn.Close(); } break; } }