
Como guardar los datos de un datagridview en una tabla con acces
Publicado por vicky (8 intervenciones) el 23/03/2015 05:22:29
Soy nueva en esto, y se me esta dificultando esto de la programacion. Tengo un formulario enlazado a una base de datos en access, la base de datos se llama SMT, y tiene 5 tablas, Inspectores, Modelos, Componentes, Defectos los cuales estan relacionados, de ella obtengo los datos para los ComboBox, la 5 tabla se llama ReporteGP12, y es la que utilizo para mostrar los campos para el Datagridview, el boton crear inserta los datos y los muestra en el datagridview, pero no los almacena en la tabla ReportesGP12, y yo necesito que esos datos se vayan almacenando.
Gracias!
Imports System.Data.OleDb
Imports System.Data
Public Class Form1
Private Sub conFoco(ByVal sender As Object, ByVal e As System.EventArgs)
DirectCast(sender, TextBox).BackColor = Color.Yellow
End Sub
Private Sub sinFoco(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.BackColorChanged
DirectCast(sender, TextBox).BackColor = Color.White
End Sub
Private Sub Id_InspectorComboBox_GotFocus(sender As Object, e As System.EventArgs) Handles Id_InspectorComboBox.GotFocus
Id_InspectorComboBox.BackColor = Color.Yellow
End Sub
Private Sub Id_InspectorComboBox_LostFocus(sender As Object, e As System.EventArgs) Handles Id_InspectorComboBox.LostFocus
Id_InspectorComboBox.BackColor = Color.White
End Sub
Private Sub ModeloComboBox_GotFocus(sender As Object, e As System.EventArgs) Handles ModeloComboBox.GotFocus
ModeloComboBox.BackColor = Color.Yellow
End Sub
Private Sub ModeloComboBox_LostFocus(sender As Object, e As System.EventArgs) Handles ModeloComboBox.LostFocus
ModeloComboBox.BackColor = Color.White
End Sub
Private Sub ComponenteComboBox_GotFocus(sender As Object, e As System.EventArgs) Handles ComponenteComboBox.GotFocus
ComponenteComboBox.BackColor = Color.Yellow
End Sub
Private Sub ComponenteCombobox_LostFocus(sender As Object, e As System.EventArgs) Handles ComponenteComboBox.LostFocus
ComponenteComboBox.BackColor = Color.White
End Sub
Private Sub Codigo_DefectoComboBox_GotFocus(sender As Object, e As System.EventArgs) Handles Codigo_DefectoComboBox.GotFocus
Codigo_DefectoComboBox.BackColor = Color.Yellow
End Sub
Private Sub Codigo_DefectoComboBox_LostFocus(sender As Object, e As System.EventArgs) Handles Codigo_DefectoComboBox.LostFocus
Codigo_DefectoComboBox.BackColor = Color.White
End Sub
Private Sub ReporteGP12BindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ReporteGP12BindingNavigatorSaveItem.Click
Me.Validate()
Me.ReporteGP12BindingSource.EndEdit()
Me.TableAdapterManager.UpdateAll(Me.SMTDataSet)
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
For Each c As Object In Me.Controls
If c.GetType Is GetType(TextBox) Then
AddHandler (DirectCast(c, TextBox).GotFocus), AddressOf conFoco
AddHandler (DirectCast(c, TextBox).LostFocus), AddressOf sinFoco
End If
'TODO: This line of code loads data into the 'SMTDataSet.Defectos' table. You can move, or remove it, as needed.
Me.DefectosTableAdapter.Fill(Me.SMTDataSet.Defectos)
'TODO: This line of code loads data into the 'SMTDataSet.Componente' table. You can move, or remove it, as needed.
Me.ComponenteTableAdapter.Fill(Me.SMTDataSet.Componente)
'TODO: This line of code loads data into the 'SMTDataSet.Modelos' table. You can move, or remove it, as needed.
Me.ModelosTableAdapter.Fill(Me.SMTDataSet.Modelos)
'TODO: This line of code loads data into the 'SMTDataSet.Inspectores' table. You can move, or remove it, as needed.
Me.InspectoresTableAdapter.Fill(Me.SMTDataSet.Inspectores)
'TODO: This line of code loads data into the 'SMTDataSet.ReporteGP12' table. You can move, or remove it, as needed.
Me.ReporteGP12TableAdapter.Fill(Me.SMTDataSet.ReporteGP12)
Next
End Sub
Private Sub Crear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Crear.Click
Me.ReporteGP12TableAdapter.Insert(FechaDateTimePicker.Text, Id_InspectorComboBox.Text, ModeloComboBox.Text, SerialTextBox.Text, LoteTextBox.Text, ComponenteComboBox.Text, Codigo_DefectoComboBox.Text, Numero_de_DefectosTextBox.Text, Total_InspeccionadoTextBox.Text)
Me.ReporteGP12TableAdapter.Fill(SMTDataSet.ReporteGP12)
Call LimpiaObjetos(Me)
End Sub
Private Function SaveOptions() As IButtonControl
Throw New NotImplementedException
End Function
Private Sub ExportarEXCEL_Click(sender As Object, e As EventArgs) Handles ExportarEXCEL.Click
llenarExcel(ReporteGP12DataGridView)
End Sub
Private Sub GroupBox1_Enter(sender As Object, e As EventArgs)
End Sub
Private Function Control() As Object
Throw New NotImplementedException
End Function
Private Sub Id_InspectorComboBox_SelectedIndexChanged(sender As Object, e As EventArgs) Handles Id_InspectorComboBox.SelectedIndexChanged
End Sub
Private Sub ModeloComboBox_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ModeloComboBox.SelectedIndexChanged
End Sub
End Class
Gracias!
Imports System.Data.OleDb
Imports System.Data
Public Class Form1
Private Sub conFoco(ByVal sender As Object, ByVal e As System.EventArgs)
DirectCast(sender, TextBox).BackColor = Color.Yellow
End Sub
Private Sub sinFoco(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.BackColorChanged
DirectCast(sender, TextBox).BackColor = Color.White
End Sub
Private Sub Id_InspectorComboBox_GotFocus(sender As Object, e As System.EventArgs) Handles Id_InspectorComboBox.GotFocus
Id_InspectorComboBox.BackColor = Color.Yellow
End Sub
Private Sub Id_InspectorComboBox_LostFocus(sender As Object, e As System.EventArgs) Handles Id_InspectorComboBox.LostFocus
Id_InspectorComboBox.BackColor = Color.White
End Sub
Private Sub ModeloComboBox_GotFocus(sender As Object, e As System.EventArgs) Handles ModeloComboBox.GotFocus
ModeloComboBox.BackColor = Color.Yellow
End Sub
Private Sub ModeloComboBox_LostFocus(sender As Object, e As System.EventArgs) Handles ModeloComboBox.LostFocus
ModeloComboBox.BackColor = Color.White
End Sub
Private Sub ComponenteComboBox_GotFocus(sender As Object, e As System.EventArgs) Handles ComponenteComboBox.GotFocus
ComponenteComboBox.BackColor = Color.Yellow
End Sub
Private Sub ComponenteCombobox_LostFocus(sender As Object, e As System.EventArgs) Handles ComponenteComboBox.LostFocus
ComponenteComboBox.BackColor = Color.White
End Sub
Private Sub Codigo_DefectoComboBox_GotFocus(sender As Object, e As System.EventArgs) Handles Codigo_DefectoComboBox.GotFocus
Codigo_DefectoComboBox.BackColor = Color.Yellow
End Sub
Private Sub Codigo_DefectoComboBox_LostFocus(sender As Object, e As System.EventArgs) Handles Codigo_DefectoComboBox.LostFocus
Codigo_DefectoComboBox.BackColor = Color.White
End Sub
Private Sub ReporteGP12BindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ReporteGP12BindingNavigatorSaveItem.Click
Me.Validate()
Me.ReporteGP12BindingSource.EndEdit()
Me.TableAdapterManager.UpdateAll(Me.SMTDataSet)
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
For Each c As Object In Me.Controls
If c.GetType Is GetType(TextBox) Then
AddHandler (DirectCast(c, TextBox).GotFocus), AddressOf conFoco
AddHandler (DirectCast(c, TextBox).LostFocus), AddressOf sinFoco
End If
'TODO: This line of code loads data into the 'SMTDataSet.Defectos' table. You can move, or remove it, as needed.
Me.DefectosTableAdapter.Fill(Me.SMTDataSet.Defectos)
'TODO: This line of code loads data into the 'SMTDataSet.Componente' table. You can move, or remove it, as needed.
Me.ComponenteTableAdapter.Fill(Me.SMTDataSet.Componente)
'TODO: This line of code loads data into the 'SMTDataSet.Modelos' table. You can move, or remove it, as needed.
Me.ModelosTableAdapter.Fill(Me.SMTDataSet.Modelos)
'TODO: This line of code loads data into the 'SMTDataSet.Inspectores' table. You can move, or remove it, as needed.
Me.InspectoresTableAdapter.Fill(Me.SMTDataSet.Inspectores)
'TODO: This line of code loads data into the 'SMTDataSet.ReporteGP12' table. You can move, or remove it, as needed.
Me.ReporteGP12TableAdapter.Fill(Me.SMTDataSet.ReporteGP12)
Next
End Sub
Private Sub Crear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Crear.Click
Me.ReporteGP12TableAdapter.Insert(FechaDateTimePicker.Text, Id_InspectorComboBox.Text, ModeloComboBox.Text, SerialTextBox.Text, LoteTextBox.Text, ComponenteComboBox.Text, Codigo_DefectoComboBox.Text, Numero_de_DefectosTextBox.Text, Total_InspeccionadoTextBox.Text)
Me.ReporteGP12TableAdapter.Fill(SMTDataSet.ReporteGP12)
Call LimpiaObjetos(Me)
End Sub
Private Function SaveOptions() As IButtonControl
Throw New NotImplementedException
End Function
Private Sub ExportarEXCEL_Click(sender As Object, e As EventArgs) Handles ExportarEXCEL.Click
llenarExcel(ReporteGP12DataGridView)
End Sub
Private Sub GroupBox1_Enter(sender As Object, e As EventArgs)
End Sub
Private Function Control() As Object
Throw New NotImplementedException
End Function
Private Sub Id_InspectorComboBox_SelectedIndexChanged(sender As Object, e As EventArgs) Handles Id_InspectorComboBox.SelectedIndexChanged
End Sub
Private Sub ModeloComboBox_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ModeloComboBox.SelectedIndexChanged
End Sub
End Class
Valora esta pregunta


0