
05/01/2009, 17:10
|
 | | | Fecha de Ingreso: abril-2008
Mensajes: 39
Antigüedad: 16 años, 11 meses Puntos: 0 | |
Respuesta: Ayuda en C# para novato y aquí sigue
Código:
else
{
if (VGlobales.VHipotecaCr != null)
{
try
{
con = new SqlConnection(sCnn);
con.Open();
SqlDataAdapter da = new SqlDataAdapter(
"SELECT fi.numfix_s, fi.zoneactiv_n, fi.streetactiv_s," +
"fi.references_s, fi.description_s" +
" FROM fixassets fi LEFT JOIN mortgage mo" +
" ON fi.numfix_s = mo.numfix_s JOIN loansxmortgage lm" +
" ON mo.numfix_s = lm.numfix_s JOIN creditos cr " +
" ON lm.cod_cre = cr.cod_cre" +
" WHERE cr.cod_cre = '" + VGlobales.VHipotecaCr + "'", con);
dt = new DataTable();
da.Fill(dt);
if (dt.Rows.Count > 0)
{
fila = 0;
MostrarDatos(fila);
}
}
catch (Exception ex)
{
MessageBox.Show("Error al conectarse a la base de datos:\n" +
ex.Message, "Conectar con la base", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
finally
{
if (con != null)
{
con.Close();
}
}
}
else
{
if (VGlobales.VHipotecaIn != null)
{
try
{
con = new SqlConnection(sCnn);
con.Open();
SqlDataAdapter da = new SqlDataAdapter(
"SELECT fi.numfix_s, fi.zoneactiv_n, fi.streetactiv_s," +
"fi.references_s, fi.description_s" +
" FROM fixassets fi LEFT JOIN mortgage mo" +
" ON fi.numfix_s = mo.numfix_s" +
" JOIN mortage_inscription mi ON mo.numfix_s = mi.numfix_s" +
" WHERE mi.num_regis_s ='" + VGlobales.VHipotecaIn + "'", con);
dt = new DataTable();
da.Fill(dt);
if (dt.Rows.Count > 0)
{
fila = 0;
MostrarDatos(fila);
}
}
catch (Exception ex)
{
MessageBox.Show("Error al conectarse a la base de datos:\n" +
ex.Message, "Conectar con la base", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
finally
{
if (con != null)
{
con.Close();
}
}
}
else
{
if (VGlobales.VHipotecaAp != null)
{
try
{
con = new SqlConnection(sCnn);
con.Open();
SqlDataAdapter da = new SqlDataAdapter(
"SELECT RTRIM(LTRIM(cu.pri_ape))+' '+RTRIM(LTRIM(cu.seg_ape))" +
"+' '+RTRIM(LTRIM(cu.ter_ape)),RTRIM(LTRIM(cu.nombre))+' '+" +
"RTRIM(LTRIM(cu.seg_nom)),fi.numfix_s, fi.zoneactiv_n," +
"fi.streetactiv_s, fi.references_s, fi.description_s FROM" +
" fixassets fi LEFT JOIN customerXfixassets cf ON fi.numfix_s = cf.numfix_s" +
" JOIN customer cu ON cf.num_cli = cu.num_cli" +
" WHERE cu.pri_ape = '" + VGlobales.VHipotecaAp + "'", con);
dt = new DataTable();
da.Fill(dt);
if (dt.Rows.Count > 0)
{
fila = 0;
MostrarDatos(fila);
}
}
catch (Exception ex)
{
MessageBox.Show("Error al conectarse a la base de datos:\n" +
ex.Message, "Conectar con la base", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
finally
{
if (con != null)
{
con.Close();
}
}
}
else
{
try
{
con = new SqlConnection(sCnn);
con.Open();
string sSel = "SELECT numfix_s, zoneactiv_n, streetactiv_s," +
"references_s, description_s" +
" FROM fixassets" +
" WHERE numfix_s ='33000038'";
da = new SqlDataAdapter(sSel, sCnn);
dt = new DataTable();
da.Fill(dt);
if (dt.Rows.Count > 0)
{
fila = 0;
MostrarDatos(fila);
}
MessageBox.Show("Conexion establecida");
}
catch (Exception ex)
{
MessageBox.Show("Error al conectarse a la base de datos:\n" +
ex.Message, "Conectar con la base", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
finally
{
if (con != null)
{
con.Close();
}
}
}
}
}
}
}
}
}
private void MostrarDatos(int f)
{
DataRow dr = dt.Rows[fila];
Propiedad.Text = dr["numfix_s"].ToString();
Zona.Text = dr["zoneactiv_n"].ToString();
Direccion.Text = dr["streetactiv_s"].ToString();
Referencia.Text = dr["references_s"].ToString();
Descripcion.Text = dr["description_s"].ToString();
}
private void toolStripButton1_Click_1(object sender, EventArgs e)
{
FrmBusquedaPropiedad frmBusPro = new FrmBusquedaPropiedad();
frmBusPro.WindowState = FormWindowState.Normal;
frmBusPro.Show();
}
}
}
Se me conecta correctamente el formulario con el dato 33000038 que pongo directamente para probar la conexión y si funciona.
Por lo que solicito su valiosa ayuda de que puedo hacer, que error tengo o que link me recomendarían leer para poder resolver dicho problema (¿No se si necesitarían que colocara las imágenes de los formularios?).
De antemano muchas gracias por su ayuda y disculpas por perder su tiempo. |