public Int32 GetValueTabla(Int32 numRegistro, string tabla, string indexName, string nombreIndex) { Int32 Curvalue = 0; try { string query = "select " + nombreIndex + " from " + tabla + " where " + indexName + "=" + numRegistro.ToString(); OleDbCommand com = new OleDbCommand(); com.Connection = GetConnection(); com.CommandText = query; OleDbDataReader resuldata = com.ExecuteReader(); if (resuldata.HasRows) { resuldata.Read(); System.Type curType = resuldata.GetType(); Curvalue = resuldata.GetInt32(0); if (curType == typeof(Int32)) { Curvalue = resuldata.GetInt32(0); } if (curType == typeof(Int16)) { Curvalue = System.Convert.ToInt32(resuldata.GetInt16(0)); } if (curType == typeof(Int64)) { Curvalue = System.Convert.ToInt32(resuldata.GetInt64(0)); } if (curType == typeof(Byte)) { Curvalue = System.Convert.ToInt32(resuldata.GetByte(0)); } } } catch (Exception e) { MessageBox.Show(e.Message, "Exception: GetNombreTabla"); return(0); } return(Curvalue); }