Ver Mensaje Individual
  #2 (permalink)  
Antiguo 05/01/2009, 17:08
Avatar de Srkuen
Srkuen
 
Fecha de Ingreso: abril-2008
Mensajes: 39
Antigüedad: 16 años
Puntos: 0
Respuesta: Ayuda en C# para novato

Y en el formulario principal que todavía no he terminado esta así:
[CODE]
Código:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace wfaInicio
{
    public partial class FrmActualizacion : Form
    {
        public FrmActualizacion()
        {
            InitializeComponent();
        }

        private DataTable dt;
        private DataSet ds;
        private SqlDataAdapter da;
        private int fila;
        private SqlConnection con = null;
        private string sCnn = "data source=ITDEV10; Initial catalog=Lalibertad; user id=sa;" +
            "password=123456;";
        private string sCnn2 = "data source=ITDEV10; Initial catalog=CustodyValue; user id=sa;" +
            "password=123456;";

        private void FrmActualizacion_Load(object sender, EventArgs e)
        {
            if (VGlobales.VHipotecaPp != null)
            {
                try
                {
                    con = new SqlConnection(sCnn);
                    con.Open();
                    SqlDataAdapter da = new SqlDataAdapter(
                        "SELECT numfix_s, zoneactiv_n, streetactiv_s, references_s," +
                        "description_s FROM fixassets" +
                        " WHERE numfix_s ='" + VGlobales.VHipotecaPp + "'", 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.VHipotecaAn != 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" +
                            " WHERE mo.annot_prev_s ='" + VGlobales.VHipotecaAn + "'", 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.VHipotecaPr != 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_pres_s = '" + VGlobales.VHipotecaPr + "'", 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();
                            }
                        }
                    }
y continua