Ver Mensaje Individual
  #3 (permalink)  
Antiguo 27/01/2011, 18:06
alien51
 
Fecha de Ingreso: julio-2010
Mensajes: 8
Antigüedad: 13 años, 9 meses
Puntos: 0
Respuesta: No se actualizan los datos en una forma de VS 2010

Gracias..

Código Load:

Código Visual Basic:
Ver original
  1. Private Sub cursos_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  2.     Try
  3.     Me.con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & "c:\cursosDB\alumnos.mdb; Persist Security Info=False"
  4.        con.Open()
  5.     dta = New OleDbDataAdapter("Select * from cursos order by nombre", con)
  6.     dtap = New OleDbDataAdapter("Select * from meses order by nombre", con)
  7.     dcon = New OleDbDataAdapter("Select * from contador order by regnum", con)
  8.     Dim oCB As OleDbCommandBuilder = New OleDbCommandBuilder(dta)
  9.     dst = New DataSet
  10.     dta.Fill(dst, "cursos")
  11.     dtap.Fill(dst, "meses")
  12.     dcon.Fill(dst, "contador")
  13.     Me.dgView.DataSource = dst
  14.     Me.dgView.DataMember = "cursos"
  15.     If Me.dst.Tables("cursos").Rows.Count <= 0 Then
  16.       ClNuevo = "SI"
  17.       Me.tbNuevo.PerformClick()
  18.     Else
  19.       vNumeroAlumnos = Me.dst.Tables("cursos").Rows.Count()
  20.       vIngresoMensual = vNumeroAlumnos * 35
  21.       TotalFecha()
  22.       ClNuevo = "NO"
  23.       IposAct = 0
  24.       cargaDatos()
  25.       Botones("BASE")
  26.       txtNumAl.Text = vNumeroAlumnos
  27.       txtMatricula.Text = String.Format("{0:n2}", vMatricula)
  28.      End If
  29.     Catch ex As Exception
  30.     MessageBox.Show(ex.Message)
  31.     End Try
  32.   End Sub

Código Grabar:

Código Visual Basic:
Ver original
  1. Private Sub tbGrabar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tbGrabar.Click
  2.     Dim nuevo As New alumnos
  3.     With nuevo
  4.       .nombre = txtNombre.Text
  5.       .dia = cmbDia.SelectedItem
  6.       .edad = cmbEdad.SelectedItem
  7.       .grupo = cmbGrupo.SelectedItem
  8.       .hora = cmbHora.SelectedItem
  9.       .acudiente = txtAcudiente.Text
  10.     End With
  11.     nuevo.meses = Month(txtInicio.Text)
  12.     vMes = nuevo.elmes
  13.     nuevo.ano = txtInicio.Text
  14.     vAno = nuevo.elano
  15.     If nuevo.nombre = "" Or nuevo.dia = "" Or nuevo.edad = "" Or nuevo.grupo = "" Or nuevo.hora = "" Or nuevo.acudiente = "" Then
  16.       MsgBox("Los campor marcados ** no pueden estar en blanco")
  17.       reset()
  18.       Exit Sub
  19.     Else
  20.       cmd = con.CreateCommand
  21.       cmd.Connection = con
  22.       Dim Trans As OleDbTransaction
  23.       Trans = con.BeginTransaction
  24.       cmd.Transaction = Trans
  25.       Try
  26.         cmd.CommandText = "INSERT into cursos (id,nombre,edad,colegio,inicio,grupo,dia,hora,acudiente,telof,telcel,telres,email,notas,saldo,total,ultimomes) values ('" & vUltimo & "', '" & nuevo.nombre & "', '" & nuevo.edad & "', '" & txtColegio.Text & "', '" & txtInicio.Text & "', '" & nuevo.grupo & "', '" & nuevo.dia & "', '" & nuevo.hora & "', '" & nuevo.acudiente & "', '" & txtTelof.Text & "', '" & txtTelcel.Text & "', '" & txtTelres.Text & "', '" & txtEmail.Text & "', '" & txtNotas.Text & "', '" & txtMatricula.Text & "',0, '" & vMes & "')"
  27.         cmd.ExecuteNonQuery()
  28.         cmd.CommandText = "INSERT into meses (id,nombre,monto,mesactual,status,ano) values ('" & vUltimo & "', '" & txtNombre.Text & "', '" & txtMatricula.Text & "','" & vMes & "','ACTIVO','" & vAno & "')"
  29.         cmd.ExecuteNonQuery()
  30.         Trans.Commit()
  31.         MessageBox.Show("Alumno Creado OK")
  32.       Catch ex As OleDbException
  33.         Trans.Rollback()
  34.         MessageBox.Show("Error al conectar con datos" & ControlChars.CrLf & ex.Message & ControlChars.CrLf & ex.Message)
  35.       End Try
  36.     End If
  37.  
  38.   End Sub

Cargadatos (Funciona tambien para actualizar el DataGridView)

Código Visual Basic:
Ver original
  1. Private Sub cargaDatos()
  2.     If ClNuevo = "SI" Then
  3.       Exit Sub
  4.     End If
  5.     txtBuscar.Text = ""
  6.     txtNombre.Focus()
  7.     Dim dtr As DataRow
  8.     dtr = Me.dst.Tables("Cursos").Rows(Me.IposAct)
  9.     vSaldo = dtr("saldo")
  10.     vTotal = dtr("total")
  11.     vId = dtr("id")
  12.     posChange()
  13.     If dtr("nombre") Is DBNull.Value Then
  14.       Me.txtNombre.Text = ""
  15.     Else
  16.       Me.txtNombre.Text = dtr("nombre")
  17.     End If
  18.     If dtr("acudiente") Is DBNull.Value Then
  19.       Me.txtAcudiente.Text = ""
  20.     Else
  21.       Me.txtAcudiente.Text = dtr("acudiente")
  22.     End If
  23.     If dtr("telcel") Is DBNull.Value Then
  24.       Me.txtTelcel.Text = ""
  25.     Else
  26.       Me.txtTelcel.Text = dtr("telcel")
  27.     End If
  28.     If dtr("colegio") Is DBNull.Value Then
  29.       Me.txtColegio.Text = ""
  30.     Else
  31.       Me.txtColegio.Text = dtr("colegio")
  32.     End If
  33.     If dtr("dia") Is DBNull.Value Then
  34.       Me.txtDia.Text = ""
  35.     Else
  36.       Me.txtDia.Text = dtr("dia")
  37.     End If
  38.     If dtr("edad") Is DBNull.Value Then
  39.       Me.txtEdad.Text = ""
  40.     Else
  41.       Me.txtEdad.Text = dtr("edad")
  42.     End If
  43.     If dtr("email") Is DBNull.Value Then
  44.       Me.txtEmail.Text = ""
  45.     Else
  46.       Me.txtEmail.Text = dtr("email")
  47.     End If
  48.     If dtr("grupo") Is DBNull.Value Then
  49.       Me.txtGrupo.Text = ""
  50.     Else
  51.       Me.txtGrupo.Text = dtr("grupo")
  52.     End If
  53.     If dtr("hora") Is DBNull.Value Then
  54.       Me.txtHora.Text = ""
  55.     Else
  56.       Me.txtHora.Text = dtr("hora")
  57.     End If
  58.     If dtr("inicio") Is DBNull.Value Then
  59.       Me.txtInicio.Text = ""
  60.     Else
  61.       Me.txtInicio.Text = dtr("inicio")
  62.     End If
  63.     If dtr("telof") Is DBNull.Value Then
  64.       Me.txtTelof.Text = ""
  65.     Else
  66.       Me.txtTelof.Text = dtr("telof")
  67.     End If
  68.     If dtr("telres") Is DBNull.Value Then
  69.       Me.txtTelres.Text = ""
  70.     Else
  71.       Me.txtTelres.Text = dtr("telres")
  72.     End If
  73.     If dtr("saldo") Is DBNull.Value Then
  74.       Me.txtSaldo.Text = 0
  75.     Else
  76.       Me.txtSaldo.Text = String.Format("{0:n2}", vSaldo) 'dtr("saldo")
  77.     End If
  78.     If dtr("ultimomes") Is DBNull.Value Then
  79.       Me.txtUltimoMes.Text = ""
  80.     Else
  81.       Me.txtUltimoMes.Text = dtr("ultimomes")
  82.     End If
  83.     If dtr("ultimopago") Is DBNull.Value Then
  84.       Me.txtUltimoPago.Text = ""
  85.     Else
  86.       Me.txtUltimoPago.Text = dtr("ultimopago")
  87.     End If
  88.     txtIngresoMensual.Text = String.Format("{0:n2}", vIngresoMensual)
  89.     RegInfo()
  90.    End Sub

Como decía, funciona perfecto al grabar el registro pero no se actualiza la forma (la pantalla) con los nuevos datos.

Nota: soy nuevito aquí y no sé como mover el post a otro lado