Foros del Web » Programando para Internet » ASPX (.net) »

Error CS0161

Estas en el tema de Error CS0161 en el foro de ASPX (.net) en Foros del Web. Hola tengo un error que me dice lo siguente CS0161: 'ASP.Visitante_aspx.LoadData(string)': no todas las rutas de código devuelven un valor Línea 170: bool LoadData(string sKey) ...
  #1 (permalink)  
Antiguo 23/09/2005, 14:23
Avatar de Sayra  
Fecha de Ingreso: diciembre-2004
Mensajes: 365
Antigüedad: 19 años, 4 meses
Puntos: 1
Error CS0161

Hola tengo un error que me dice lo siguente

CS0161: 'ASP.Visitante_aspx.LoadData(string)': no todas las rutas de código devuelven un valor

Línea 170: bool LoadData(string sKey)


bool LoadData(string sKey)
{
string sTmp;
bool bRead;

// Get Connection String
string sConnStr = ewdb.ewConnStr();

// Construct SQL statement
string sKeyWrk = "" + sKey + "";
string sSelect = "SELECT * FROM [T_VISITANTE] WHERE [visi_id] = " + sKeyWrk;
lblSql.Text = sSelect;

// Create a new Connection Object using the Connection String
SqlConnection oConn = new SqlConnection(sConnStr);

// Open the Connection to the Database
oConn.Open();

// Create DataReader Object and Get Data from Database
SqlDataReader drWrk = ewdb.ewDataReader(oConn, sSelect);
if (drWrk == null)
{
lblMessage.Text = Convert.ToString(Session["dberrmsg"]);
lblSql.Visible = true;
oConn.Close(); // Close Connection
return false; // Error Return and Stop Execution
}
else
{
lblSql.Visible = false;
}
bRead = drWrk.Read();
if (bRead)
{

// Field empl_id
string sConn_empl_id = ewdb.ewConnStr();
DataView ewdv_empl_id;
string sFilter_empl_id;
sFilter_empl_id = "";
ewdv_empl_id = ewdb.ewDataViewLink(sConn_empl_id, "T_EMPLEADOS", "empl_id", "empl_nom", "empl_ape", "", "", "", false, sFilter_empl_id);
if (ewdv_empl_id == null)
{

//x_empl_id.Items.Insert(0,new ListItem(Convert.ToString(Session["dberrmsg"]),""));
}
else
{
x_empl_id.DataSource = ewdv_empl_id;
x_empl_id.DataTextField = "ewTextField";
x_empl_id.DataValueField = "ewValueField";
x_empl_id.DataBind();
x_empl_id.Items.Insert(0,new ListItem("Please Select",""));
if (drWrk["empl_id"] != DBNull.Value)
{
foreach (ListItem li_empl_id in x_empl_id.Items)
{
if (Convert.ToString(li_empl_id.Value) == Convert.ToString(drWrk["empl_id"]))
{
li_empl_id.Selected = true;
}
}
}
}

// Field visi_nom
if (drWrk["visi_nom"] != DBNull.Value)
{
x_visi_nom.Text = Convert.ToString(drWrk["visi_nom"]);
}

// Field visi_ape
if (drWrk["visi_ape"] != DBNull.Value)
{
x_visi_ape.Text = Convert.ToString(drWrk["visi_ape"]);
}

// Field visi_ced
if (drWrk["visi_ced"] != DBNull.Value)
{
x_visi_ced.Text = Convert.ToString(drWrk["visi_ced"]);
}



// Close DataReader
drWrk.Close();

// Close connection
oConn.Close();
if (bRead)
{
return true; // Normal Return
}
else
{
return false; // Record not found
}
}
}
// End LoadData

Gracias de antemano
  #2 (permalink)  
Antiguo 23/09/2005, 14:52
Avatar de xknown  
Fecha de Ingreso: diciembre-2004
Ubicación: Cusco - Perú
Mensajes: 2.248
Antigüedad: 19 años, 3 meses
Puntos: 7
Hola, el error que te manda es porque no haces un return _genérico_...bah, mejor te pongo estos ejemplos:
Código:
 // No compila
public bool par(int y){
  if  (y % 2 == 0)
    return false;
}
// Si compila
public bool par(int y){
  if (y % 2 == 0)
    return false;
  else
    return true;
}
// Tambien compila
public bool par(int y){
  if (y %2 == 0)
    return false;
  return true;
}
Si el código que pusiste estuviera indentado y de preferencia encerrado entre etiquetas [ code]..[ /code] (sin los espacios) dicho error sería fácilmente identificable.

Saludos
__________________
Alex Concha
Buayacorp - Programación y Diseño
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta

SíEste tema le ha gustado a 1 personas (incluyéndote)




La zona horaria es GMT -6. Ahora son las 12:01.