public static string GetDispositivoStampaUtente(string idPeople) { DocsPaDB.Query_DocsPAWS.Amministrazione amm = new DocsPaDB.Query_DocsPAWS.Amministrazione(); List <DocsPaVO.amministrazione.DispositivoStampaEtichetta> list = amm.GetDispositiviStampaEtichetta(); string stringa_dispositivo = ""; DocsPaUtils.Query queryDef_stampautente = DocsPaUtils.InitQuery.getInstance().getQuery("S_GET_DISPOSITIVO_STAMPA_UTENTE"); queryDef_stampautente.setParam("idPeople", idPeople); string cm_stampautente = queryDef_stampautente.getSQL(); logger.Debug(cm_stampautente); using (DBProvider dbProvider = new DBProvider()) { using (System.Data.IDataReader reader = dbProvider.ExecuteReader(cm_stampautente)){ while (reader.Read()) { if (reader.GetValue(0) != DBNull.Value) { stringa_dispositivo = list.Find(x => x.Id == int.Parse(reader.GetValue(0).ToString())).Code; } else { stringa_dispositivo = list.Find(x => x.Id == int.Parse(reader.GetValue(1).ToString())).Code; } } } } return(stringa_dispositivo); }
public List <ImportProductCatalogueEntity> ImportDatatoCatalogue(int StoreId, int LoggedInUserId, int supplier_id, int language_id, int catalogue_id, DataTable XLS, bool IsConfirmToIgnore) { try { SqlConnection con = new SqlConnection(); con.ConnectionString = Convert.ToString(ConfigurationManager.ConnectionStrings["DefaultConnection"]); con.Open(); SqlCommand cmd = new SqlCommand("ImportCatalogueDataToTable", con); cmd.CommandType = CommandType.StoredProcedure; SqlParameter parameter = new SqlParameter(); parameter.ParameterName = "@importTypetbl"; parameter.SqlDbType = SqlDbType.Structured; parameter.TypeName = "dbo.ImportCatalogType2"; parameter.Value = XLS; cmd.Parameters.Add(parameter); cmd.Parameters.AddWithValue("@Supplier_Id", supplier_id); cmd.Parameters.AddWithValue("@Language_Id", language_id); cmd.Parameters.AddWithValue("@Catalogue_Id", catalogue_id); cmd.Parameters.AddWithValue("@CreatedBy", LoggedInUserId); cmd.Parameters.AddWithValue("@IsConfirmToIgnore", IsConfirmToIgnore); cmd.CommandTimeout = 120000000; System.Data.IDataReader dr = cmd.ExecuteReader(); List <ImportProductCatalogueEntity> lstEntity = new List <ImportProductCatalogueEntity>(); while (dr.Read()) { ImportProductCatalogueEntity objEntity = new ImportProductCatalogueEntity(); objEntity.code = Convert.ToString(dr.GetValue(0)); objEntity.name = Convert.ToString(dr.GetValue(1)); lstEntity.Add(objEntity); //result = Convert.ToInt32(dr[0]); } dr.Close(); //tvpParam.TypeName = "dbo.ImportCatalogType"; // int result = 0; //result = cmd.ExecuteNonQuery(); // result = Convert.ToInt32(cmd.ExecuteScalar()); //System.Data.IDataReader dr = cmd.ExecuteReader(); //while (dr.Read()) //{ // result = Convert.ToInt32(dr[0]); //} //dr.Close(); con.Close(); return(lstEntity); } catch (Exception ex) { throw; } }
public static DocsPaVO.amministrazione.EsitoOperazione ImpostaLivelloSottoUO(DocsPaVO.amministrazione.OrgUO currentUO, string segno, int delta) { int rowsAffected; string commandText = string.Empty; string condizioneLivello = string.Empty; DocsPaUtils.Query queryDef = null; DocsPaDB.DBProvider dbProvider = new DocsPaDB.DBProvider(); DocsPaDB.DBProvider dbProvider2 = new DocsPaDB.DBProvider(); System.Data.IDataReader reader = null; DocsPaVO.amministrazione.EsitoOperazione esito = new DocsPaVO.amministrazione.EsitoOperazione(); DocsPaVO.amministrazione.OrgUO sottoUO = null; // prende tutte le sotto UO queryDef = DocsPaUtils.InitQuery.getInstance().getQuery("S_CORR_GLOB_GENERIC"); queryDef.setParam("param1", "SYSTEM_ID, NUM_LIVELLO"); queryDef.setParam("param2", "ID_PARENT = " + currentUO.IDCorrGlobale); commandText = queryDef.getSQL(); logger.Debug(commandText); reader = dbProvider.ExecuteReader(commandText); while (reader.Read()) { sottoUO = new DocsPaVO.amministrazione.OrgUO(); sottoUO.IDCorrGlobale = reader.GetValue(reader.GetOrdinal("SYSTEM_ID")).ToString(); sottoUO.Livello = reader.GetValue(reader.GetOrdinal("NUM_LIVELLO")).ToString(); condizioneLivello = segno + Convert.ToString(delta); // aggiorna livello sotto UO queryDef = DocsPaUtils.InitQuery.getInstance().getQuery("U_DPACorrGlobali"); queryDef.setParam("param1", "NUM_LIVELLO = NUM_LIVELLO " + condizioneLivello); queryDef.setParam("param2", "SYSTEM_ID = " + sottoUO.IDCorrGlobale); commandText = queryDef.getSQL(); logger.Debug(commandText); dbProvider2.ExecuteNonQuery(commandText, out rowsAffected); if (rowsAffected == 0) { esito.Codice = 3; esito.Descrizione = "fallito aggiornamento del livello della UO con ID: " + sottoUO.IDCorrGlobale; break; } else { esito = ImpostaLivelloSottoUO(sottoUO, segno, delta); } } return(esito); }
/// <summary> /// Creazione oggetto "OrgFunzioneAnagrafica" da datareader /// </summary> /// <param name="reader"></param> /// <returns></returns> private static OrgFunzioneAnagrafica CreateFunzioneAnagrafica(System.Data.IDataReader reader) { OrgFunzioneAnagrafica retValue = new OrgFunzioneAnagrafica(); retValue.Codice = reader.GetValue(reader.GetOrdinal("CODICE")).ToString(); retValue.Descrizione = reader.GetValue(reader.GetOrdinal("DESCRIZIONE")).ToString(); retValue.TipoFunzione = reader.GetValue(reader.GetOrdinal("TIPO_FUNZIONE")).ToString(); return(retValue); }
public void ListDoldur900(ref ListView list, string sql) { CheckConnection(); System.Data.IDataReader rd = TSelect(sql); int i; while (rd != null && rd.Read()) { if (rd.GetValue(1).ToString().Trim() == "HATA") { m mx = new m(); mx.tistex = "HATA!"; mx.label1.Text = rd.GetValue(0).ToString().Trim(); mx.ShowDialog(); break; } else { list.Items.Clear(); } ListViewItem row = new ListViewItem(); if (rd.IsDBNull(0)) { row.Text = ""; } else { row.Text = rd.GetValue(0).ToString(); } for (i = 1; i < rd.FieldCount; i++) { if (rd.IsDBNull(i)) { row.SubItems.Add(""); } else { row.SubItems.Add(rd.GetValue(i).ToString()); } } list.Items.Add(row); } if (rd != null) { rd.Close(); } }
public List <IDictionary <string, object> > ConvertirADiccionario(ref System.Data.IDataReader lector, List <MODCampos> campos) { var _rows = new List <IDictionary <string, object> >(); var dtscheme = lector.GetSchemaTable() != null?lector.GetSchemaTable().AsEnumerable().Select(x => new { Nombre = x["ColumnName"], Orden = x["ColumnOrdinal"] }).ToDictionary(x => x.Nombre.ToString().ToLower(), x => (int)x.Orden) : null; while (lector.Read()) { Dictionary <string, object> row = new Dictionary <string, object>(); if (campos != null && campos.Count > 0) { foreach (var campo in campos) { int ord = -1; if (dtscheme.TryGetValue(campo.Nombre.ToLower(), out ord)) { row.Add(campo.Nombre.ToUpper(), lector.GetValue(ord)); } } } else { //TODO:Leer reader y generar la _rows } _rows.Add(row); } return(_rows); }
public void AutoMap(object item) { foreach (DataReaderField item2 in list_0) { if (!item2.IsSystem) { object value = idataReader_0.GetValue(item2.Index); bool flag = false; PropertyInfo value2 = null; if (dictionary_0.TryGetValue(item2.LowerName, out value2)) { method_2(item2, value2, item, value); flag = true; } else if (item2.LowerName.IndexOf('_') != -1) { flag = method_0(item, item2, value); } if (!flag && !dbCommandData_0.Context.Data.IgnoreIfAutoMapFails) { throw new FluentDataException("Could not map: " + item2.Name); } } } }
public void ListDoldurEkle(ref ListView list, string sql, string PaletID) { CheckConnection(); System.Data.IDataReader rd = TSelect(sql); for (int j = 0; j < list.Items.Count; j++) { if (PaletID.Trim() == list.Items[0].ToString().Trim()) { return; } } //list.Items.Clear(); int i; while (rd != null && rd.Read()) { ListViewItem row = new ListViewItem(); if (rd.IsDBNull(0)) { row.Text = ""; } else { row.Text = rd.GetValue(0).ToString(); } for (i = 1; i < rd.FieldCount; i++) { if (rd.IsDBNull(i)) { row.SubItems.Add(""); } else { row.SubItems.Add(rd.GetValue(i).ToString()); } } list.Items.Add(row); } if (rd != null) { rd.Close(); } }
public static void Main() { SQLRelayConnection sqlrcon = new SQLRelayConnection("Data Source=sqlrserver:9000;User ID=user;Password=password;Retry Time=0;Tries=1;Debug=false"); sqlrcon.Open(); SQLRelayCommand sqlrcom = (SQLRelayComand)sqlrcon.CreateCommand(); sqlrcom.CommandText = "select col1,col2 from exampletable"; try { System.Data.IDataReader datareader = sqlrcom.ExecuteReader(); // read row... datareader.Read(); // get the raw data of the first field in a variety of ways Object o1 = datareader.GetValue(0); o1 = datareader[0]; o1 = datareader.GetValue(datareader.GetOrdinal("col1")); o1 = datareader["col1"]; Object[] os1 = datareader.GetValues(); o1 = os1[0]; // get the first field as a string String s1 = datareader.GetString(0); // get the raw data of the second field in a variety of ways Object o2 = datareader.GetValue(1); o2 = datareader[1]; o2 = datareader.GetValue(datareader.GetOrdinal("col2")); o2 = datareader["col2"]; Object[] os2 = datareader.GetValues(); o2 = os2[1]; // get the second field as a string String s2 = datareader.GetString(1); // read another row... datareader.Read(); ... do something with this row ... ... fetch more rows ... }
//--------------------------------------------------------------------------------------------------------------------- public void LoadRegistrationInfo() { string sql = String.Format("SELECT reg_origin, reg_date FROM usrreg WHERE id_usr={0};", this.Id); System.Data.IDbConnection dbConnection = context.GetDbConnection(); System.Data.IDataReader reader = context.GetQueryResult(sql, dbConnection); if (reader.Read()) { if (reader.GetValue(0) != DBNull.Value) { RegistrationOrigin = reader.GetString(0); } if (reader.GetValue(1) != DBNull.Value) { RegistrationDate = reader.GetDateTime(1); } } context.CloseQueryResult(reader, dbConnection); }
private T GetValue <T>(int i) { var value = InnerReader.GetValue(i); if (value == DBNull.Value) { return(default(T)); } return((T)value); }
/// <summary> /// Creazione oggetto "OrgFunzione" da datareader /// </summary> /// <param name="reader"></param> /// <returns></returns> private static OrgFunzione CreateFunzione(System.Data.IDataReader reader) { OrgFunzione retValue = new OrgFunzione(); if (!reader.IsDBNull(reader.GetOrdinal("ID_ASSOCIAZIONE"))) { retValue.ID = reader.GetValue(reader.GetOrdinal("ID_ASSOCIAZIONE")).ToString(); } if (!reader.IsDBNull(reader.GetOrdinal("ID_TIPO_FUNZIONE"))) { retValue.IDTipoFunzione = reader.GetValue(reader.GetOrdinal("ID_TIPO_FUNZIONE")).ToString(); } string associato = reader.GetString(reader.GetOrdinal("ASSOCIATO")); retValue.Associato = Convert.ToBoolean(associato); retValue.FunzioneAnagrafica = CreateFunzioneAnagrafica(reader); return(retValue); }
public override T GetValue(System.Data.IDataReader dataReader) { var entity = Activator.CreateInstance <T>(); var value = dataReader.GetValue(0); if (value == null || value is DBNull) { entity = default(T); } else { var underlyingType = Nullable.GetUnderlyingType(typeof(T)); entity = (T)Convert.ChangeType(value, underlyingType ?? typeof(T)); } return(entity); }
/// <summary> /// 把数据表以CSV格式导出到文本流 /// </summary> /// <param name="writer">只写文本流</param> /// <param name="dr">数据表</param> /// <param name="headers">列头对应字典</param> /// <param name="adrs">adrs</param> public static int ExportCSV(TextWriter writer, System.Data.IDataReader dr, System.Collections.Hashtable headers, params System.Action <IDataRecord>[] adrs) { int cCount = dr.FieldCount; for (int i = 0; i < cCount; i++) { if (i != 0) { writer.Write(','); } string field = dr.GetName(i); object obj = GetHashtableValue(headers, field); if (obj == null) { writer.Write(CSVFormat(field)); } else { writer.Write(CSVFormat(obj.ToString())); } } writer.WriteLine(); int count = 0; while (dr.Read()) { count++; for (int i = 0; i < cCount; i++) { if (i != 0) { writer.Write(','); } writer.Write(CSVFormat(dr.GetValue(i))); } writer.WriteLine();// ('\r'); for (var i = 0; i < adrs.Length; i++) { adrs[i](dr); } } writer.Flush(); return(count); }
private List <Dictionary <string, object> > ExecutaQuery(System.Data.Common.DbCommand cmd) { List <Dictionary <string, object> > Linhas = new List <Dictionary <string, object> >(); try { if (cmd.CommandText.Contains("CALL ")) { cmd.CommandType = CommandType.StoredProcedure; } else { cmd.CommandType = CommandType.Text; } cmd.CommandTimeout = 1800; using (System.Data.IDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { Dictionary <string, object> linha = new Dictionary <string, object>(); // Colunas for (int i = 0; i < reader.FieldCount; i++) { linha.Add(reader.GetName(i), reader.GetValue(i) == DBNull.Value ? null : reader.GetValue(i)); } // Adiciona Dictionary da Linha Linhas.Add(linha); } } } catch (Exception ex) { string txtComando = Util.DevolveStringCommand(cmd); throw new Exception(string.Format("Erro ao executar comando no banco de dados.\r\nTexto: {0}\r\nDetalhes: {1}", txtComando, ex.Message), ex); } return(Linhas); }
internal static void setValuesFromReader <T>(T obj, d.IDataReader reader) where T : class { //reader.FieldCount for (int i = 0; i < reader.FieldCount; i++) { var fieldName = reader.GetName(i); //this might be slow this is where some mapper would be handy //if considering larger results sets //which are mostly not existing if (reader.GetFieldType(i) == typeof(byte[])) { //reader all bytes long size = reader.GetBytes(i, 0, null, 0, 0); byte[] values = new byte[size]; int bufferSize = 1024; long bytesRead = 0; int curPos = 0; while (bytesRead < size) { bytesRead += reader.GetBytes(i, curPos, values, curPos, bufferSize); curPos += bufferSize; } obj.SetValue(fieldName, values); } else { if (reader.IsDBNull(i)) { obj.SetValue(fieldName, null); } else { var value = reader.GetValue(i); obj.SetValue(fieldName, value); } } } }
/// <summary> /// Reperimento info delle ragioni trasmissione /// </summary> /// <param name="idAmministrazione"></param> /// <returns></returns> public static OrgRagioneTrasmissione[] GetInfoRagioniTrasmissione(string idAmministrazione) { ArrayList retValue = new ArrayList(); OrgRagioneTrasmissione ragione = null; DocsPaUtils.Query queryDef = DocsPaUtils.InitQuery.getInstance().getQuery("S_DPARagTrasm_ALL"); queryDef.setParam("param1", "system_id as ID, var_desc_ragione as DESCRIZIONE, cha_tipo_dest as TIPO_DESTINATARIO"); if (idAmministrazione == null || idAmministrazione.ToUpper().Equals("NULL")) { queryDef.setParam("param2", "WHERE id_amm IS NULL"); } else { queryDef.setParam("param2", "WHERE id_amm = " + idAmministrazione); } string commandText = queryDef.getSQL(); logger.Debug(commandText); using (DocsPaDB.DBProvider dbProvider = new DocsPaDB.DBProvider()) { using (System.Data.IDataReader reader = dbProvider.ExecuteReader(commandText)) { while (reader.Read()) { ragione = new OrgRagioneTrasmissione(); ragione.ID = reader.GetValue(reader.GetOrdinal("ID")).ToString(); ragione.Codice = reader.GetString(reader.GetOrdinal("DESCRIZIONE")); ragione.TipoDestinatario = OrgRagioneTrasmissione.ParseTipoDestinatario(reader.GetString(reader.GetOrdinal("TIPO_DESTINATARIO"))); retValue.Add(ragione); } } } return((OrgRagioneTrasmissione[])retValue.ToArray(typeof(OrgRagioneTrasmissione))); }
public static IEnumerable <Dictionary <string, object> > AsEnumerableDictionary(this System.Data.IDataReader source) { if (source == null) { throw new ArgumentNullException("source"); } while (source.Read()) { Dictionary <string, object> row = new Dictionary <string, object>(); for (int i = 0; i < source.FieldCount; i++) { object value = source.GetValue(i); // return an empty string for dbnull value of field type string if (source.GetFieldType(i) == typeof(string) && source.IsDBNull(i)) { value = string.Empty; } row.Add(source.GetName(i), value); } yield return(row); } }
/// <summary> /// Retrieve a record from the database. /// </summary> /// <param name="id"></param> /// <returns></returns> /// <remarks></remarks> public Datafile RetrieveDatafile(int id) { DbCommand cmd = store.GetStoredProcCommand("RetrieveDatafileByID"); store.AddInParameter(cmd, "id", DbType.String, id); using (System.Data.IDataReader reader = store.ExecuteReader(cmd)) { if (reader.Read() == true) { Datafile newfile = new Datafile(); newfile.ID = reader.GetInt32(reader.GetOrdinal("id")); newfile.Category = System.Convert.ToString(reader.SafeGetString(reader.GetOrdinal("category"))); newfile.Group = System.Convert.ToString(reader.SafeGetString(reader.GetOrdinal("group"))); newfile.Filename = System.Convert.ToString(reader.SafeGetString(reader.GetOrdinal("filename"))); newfile.Extension = System.Convert.ToString(reader.SafeGetString(reader.GetOrdinal("extension"))); newfile.Content = (byte[])(reader.GetValue(reader.GetOrdinal("content"))); return(newfile); } else { return(null); } } }
internal static void setValuesFromReader <T>(T obj, d.IDataReader reader) where T : IBattleAxe { //reader.FieldCount for (int i = 0; i < reader.FieldCount; i++) { var fieldName = reader.GetName(i); if (reader.GetFieldType(i) == typeof(byte[])) { //reader all bytes long size = reader.GetBytes(i, 0, null, 0, 0); byte[] values = new byte[size]; int bufferSize = 1024; long bytesRead = 0; int curPos = 0; while (bytesRead < size) { bytesRead += reader.GetBytes(i, curPos, values, curPos, bufferSize); curPos += bufferSize; } obj[fieldName] = values; } else { var value = reader.GetValue(i); if (reader.IsDBNull(i)) { obj[fieldName] = null; } else { obj[fieldName] = value; } } } }
/// <summary> /// Derives the parameters. /// </summary> /// <param name="provider">The provider.</param> /// <param name="command">The command.</param> private static void DeriveParameters(IDbProvider provider, IDbCommand command) { // Find the CommandBuilder if (provider == null) { throw new ArgumentNullException("provider"); } if (string.IsNullOrEmpty(provider.CommandBuilderClass)) { throw new Exception(String.Format( "CommandBuilderClass not defined for provider \"{0}\".", provider.Id)); } Type commandBuilderType = provider.CommandBuilderType; // Invoke the static DeriveParameter method on the CommandBuilder class // NOTE: OracleCommandBuilder has no DeriveParameter method //修改采用OLEDB调用Oracle数据库时,方法“DeriveParameters”执行不成功问题,采用自己的方法。 if (command.Connection is System.Data.OleDb.OleDbConnection && command.Connection.ConnectionString.ToUpper().Contains("ORAOLEDB.ORACLE.1")) { try { string commandTextOld = command.CommandText; CommandType commandTypeOld = command.CommandType; string procedureSchema = ""; string ProcedureName = ""; string sql = string.Format(@"select * from (select null PROCEDURE_CATALOG, owner PROCEDURE_SCHEMA, object_name PROCEDURE_NAME, decode(object_type, 'PROCEDURE', 2, 'FUNCTION', 3, 1) PROCEDURE_TYPE, null PROCEDURE_DEFINITION, null DESCRIPTION, created DATE_CREATED, last_ddl_time DATE_MODIFIED from all_objects where object_type in ('PROCEDURE', 'FUNCTION') union all select null PROCEDURE_CATALOG, arg.owner PROCEDURE_SCHEMA, arg.package_name || '.' || arg.object_name PROCEDURE_NAME, decode(min(arg.position), 0, 3, 2) PROCEDURE_TYPE, null PROCEDURE_DEFINITION, decode(arg.overload, '', '', 'OVERLOAD') DESCRIPTION, min(obj.created) DATE_CREATED, max(obj.last_ddl_time) DATE_MODIFIED from all_objects obj, all_arguments arg where arg.package_name is not null and arg.owner = obj.owner and arg.object_id = obj.object_id group by arg.owner, arg.package_name, arg.object_name, arg.overload) PROCEDURES WHERE PROCEDURE_NAME = '{0}' or PROCEDURE_SCHEMA||'.'||PROCEDURE_NAME ='{1}' order by 1,2, 3 ", command.CommandText.Trim(new char[] { ' ', '\n', (char)13 }), command.CommandText.Trim(new char[] { ' ', '\n', (char)13 })); command.CommandText = sql; command.CommandType = CommandType.Text; System.Data.IDataReader idataRead = command.ExecuteReader(); if (idataRead.Read()) { procedureSchema = Convert.ToString(idataRead.GetValue(1)); ProcedureName = Convert.ToString(idataRead.GetValue(2)); idataRead.Close(); } else { command.CommandText = commandTextOld; command.CommandType = commandTypeOld; throw new IbatisException("Could not retrieve parameters for the store procedure named " + command.CommandText); } sql = string.Format(@"select procedure_catalog, procedure_schema, procedure_name, parameter_name, ordinal_position, parameter_type, parameter_hasdefault, parameter_default, is_nullable, data_type, character_maximum_length, character_maximum_length character_octet_length, numeric_precision, numeric_scale, description, type_name, overload from (select null procedure_catalog, owner procedure_schema, decode(package_name, NULL, object_name, package_name || '.' || object_name) procedure_name, decode(position, 0, 'RETURN_VALUE', nvl(argument_name, chr(0))) parameter_name, position ordinal_position, decode(in_out, 'IN', 1, 'IN/OUT', 2, 'OUT', decode(argument_name, null, 4, 3), null) parameter_type, null parameter_hasdefault, null parameter_default, 65535 is_nullable, decode(data_type, 'CHAR', 129, 'NCHAR', 129, 'DATE', 135, 'FLOAT', 139, 'LONG', 129, 'LONG RAW', 128, 'NUMBER', 139, 'RAW', 128, 'ROWID', 129, 'VARCHAR2', 129, 'NVARCHAR2', 129, 'REF CURSOR', 12, 13) data_type, decode(data_type, 'CHAR', decode(data_length, null, 2000, data_length), 'LONG', 2147483647, 'LONG RAW', 2147483647, 'ROWID', 18, 'RAW', decode(data_length, null, 2000, data_length), 'VARCHAR2', decode(data_length, null, 4000, data_length), 'DATE', null, 'FLOAT', null, 'NUMBER', null, null) character_maximum_length, decode(data_type, 'DATE', 19, 'FLOAT', 15, 'NUMBER', decode(data_precision, null, 0, data_precision), 'CHAR', null, 'NCHAR', null, 'LONG', null, 'LONG RAW', null, 'RAW', null, 'VARCHAR2', null, 'NVARCHAR2', null, null) numeric_precision, decode(data_type, 'DATE', 0, 'NUMBER', decode(data_scale, null, 0, data_scale), 'CHAR', null, 'NCHAR', null, 'FLOAT', null, 'LONG', null, 'LONG RAW', null, 'RAW', null, 'VARCHAR2', null, 'NVARCHAR2', null, null) numeric_scale, null description, data_type type_name, overload from all_arguments where data_level = 0 and data_type is not null) procedure_parameters where 1 = 1 and procedure_schema = '{0}' and procedure_name = '{1}' order by 1, 2, 3, 5", procedureSchema, ProcedureName); command.CommandText = sql; command.CommandType = CommandType.Text; System.Data.IDataReader idataReadParm = command.ExecuteReader(); while (idataReadParm.Read()) { var parm = new System.Data.OleDb.OleDbParameter(Convert.ToString(idataReadParm.GetValue(3)), (System.Data.OleDb.OleDbType)Enum.Parse(typeof(System.Data.OleDb.OleDbType), Convert.ToString(idataReadParm.GetValue(9)))); switch (Convert.ToString(idataReadParm.GetValue(5))) { case "1": parm.Direction = ParameterDirection.Input; break; case "2": parm.Direction = ParameterDirection.InputOutput; break; case "3": parm.Direction = ParameterDirection.Output; break; default: parm.Direction = ParameterDirection.ReturnValue; break; } command.Parameters.Add(parm); } idataReadParm.Close(); command.CommandText = commandTextOld; command.CommandType = commandTypeOld; } catch (Exception ex) { throw new IbatisException("Could not retrieve parameters for the store procedure named " + command.CommandText, ex); } } else { try { commandBuilderType.InvokeMember("DeriveParameters", BindingFlags.Public | BindingFlags.InvokeMethod | BindingFlags.Static, null, null, new object[] { command }); } catch (Exception ex) { throw new IbatisException("Could not retrieve parameters for the store procedure named " + command.CommandText, ex); } } }
public object GetValue(int i) { return(_innerReader.GetValue(i)); }
public void TreeDoldur(ref TreeView tree, string sql) { while (conn.State == System.Data.ConnectionState.Broken || conn.State == System.Data.ConnectionState.Closed) { if (MessageBox.Show("Veri tabani baðlantisi kopuk!\nTekrar denemek istiyor musunuz?", "Baðlanti hatasi", MessageBoxButtons.OKCancel, MessageBoxIcon.Hand, MessageBoxDefaultButton.Button1) != DialogResult.OK) { STR_HataMesaji = "Veri tabani baðlantisi kopuk!"; return; } } string val; int index; tree.Nodes.Clear(); System.Data.DataTable dt = new System.Data.DataTable("t1"); dt.Columns.Add("Col1"); dt.Columns.Add("Col2"); comm.CommandText = sql; System.Data.IDataReader dr = comm.ExecuteReader(); bool r; while ((r = dr.Read())) { if (dr.IsDBNull(0) || dr.GetValue(0).ToString() == "") { val = dr.GetValue(1).ToString(); TreeNode tno = new TreeNode(val); tno.Text = val; if ((index = val.LastIndexOf('-')) > 0) { tno.Text = val.Substring(index + 1, val.Length - index - 1); } tno.ImageIndex = tno.SelectedImageIndex = GetNodeLevel(tno); tree.Nodes.Add(tno); continue; } TreeNode tn; if ((tn = FindInTree(ref tree, dr.GetValue(0).ToString())) != null) { val = dr.GetValue(1).ToString(); TreeNode tno = new TreeNode(val); tno.Text = val; if ((index = val.LastIndexOf('-')) > 0) { tno.Text = val.Substring(index + 1, val.Length - index - 1); } tno.ImageIndex = tno.SelectedImageIndex = GetNodeLevel(tno) + 1; tn.Nodes.Add(tno); } else { object[] rowVals = new object[2]; rowVals[0] = dr.GetValue(0).ToString(); rowVals[1] = dr.GetValue(1).ToString(); dt.Rows.Add(rowVals); } } dr.Close(); while (dt.Rows.Count > 0) { Random rn = new Random(DateTime.Now.Millisecond); int randnum = rn.Next(dt.Rows.Count); if (randnum == 1 && DateTime.Now.Millisecond > 500) { randnum = 0; } TreeNode tn; if ((tn = FindInTree(ref tree, dt.Rows[randnum][0].ToString())) != null) { val = dt.Rows[randnum][1].ToString(); TreeNode tno = new TreeNode(val); tno.Text = val; if ((index = val.LastIndexOf('-')) > 0) { tno.Text = val.Substring(index + 1, val.Length - index - 1); } tno.ImageIndex = tno.SelectedImageIndex = GetNodeLevel(tno) + 1; tn.Nodes.Add(tno); dt.Rows[randnum].Delete(); } } }