1
« en: Viernes 28 de Febrero de 2014, 17:19 »
Saludos, Por favor alguien q me ayude. Me Form muestra el cambio pero no se almacena an la tabla. Mi codigo es:
=============================================================================================================================================
ublic Class FrmBuscarAlumno
Dim cnn As New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\BD.mdb;Persist Security Info=True;Jet OLEDB:Database Password=195019760339")
Dim comandos As New OleDb.OleDbCommand
Dim dt As New DataTable
Dim dt2 As New DataTable
Dim dt3 As New DataTable
Dim dt4 As New DataTable
Dim da As New OleDbDataAdapter("SELECT * FROM Alumnos", cnn)
Dim da2 As New OleDbDataAdapter("SELECT * FROM Cursos", cnn)
Dim da3 As New OleDbDataAdapter("SELECT * FROM Tipos", cnn)
Dim da4 As New OleDbDataAdapter("SELECT * FROM Estados", cnn)
Dim ds As New DataSet
Dim ds2 As New DataSet
Dim ds3 As New DataSet
Dim ds4 As New DataSet
=============================================================================================================================================
Private Sub CmdGNuevo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmdGNuevo.Click
Try
'Crear la Tabla
Dim TablaAlumnos As String = "SELECT * FROM Alumnos"
' Crear un nuevo objeto del tipo DataAdapter
Using da = New OleDbDataAdapter(TablaAlumnos, cnn)
' Crear los comandos de insertar, actualizar y eliminar
Dim cb As New OleDbCommandBuilder(da)
dt = New DataTable
' Llenar la tabla con los datos indicados
da.Fill(dt)
' Crear un nuevo registro
Dim Modifica As DataRow = dt.Select("CodAlumno=" & CodAlumnoTextBox.Text)(0)
' Asignar los datos de los textbox a la fila
'asignarDatos(FilaBuscada)
Modifica("Nombres") = NombresTextBox.Text
Modifica("Apellidos") = ApellidosTextBox.Text
Modifica("Direccion") = DireccionTextBox.Text
Modifica("Telefono") = TelefonoTextBox.Text
Modifica("CodCurso") = CodCursoTextBox.Text
Modifica("Foto") = txtfoto.Text
Modifica("CodTipo") = CodTipoTextBox.Text
Modifica("CodEstado") = CodEstadoTextBox.Text
Modifica("Acudiente") = AcudienteTextBox.Text
' Añadir la nueva fila a la tabla
'dt.Rows.Add(FilaBuscada)
' Guardar físicamente los datos en la base
da.Update(dt)
dt.AcceptChanges()
cnn.Close() 'Cerramos el Form
'Me.Close()
End Using
Catch ex As Exception
MessageBox.Show("La Tabla esta Vacia, por lo que no se podran visualizar registros anteriores" & vbCrLf & _
ex.Message, "Conectar con la base", _
MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
End Class