Como agregar datos a un datagridview
Publicado por Carlos (50 intervenciones) el 15/09/2009 17:40:23
Hola a todos
Este problema me tiene ya bastante tiempo
Con esto cargo los datos a una tabla access
Primero declaro esto
Private MiAdaptadorMat As New OleDbDataAdapter("SELECT * FROM precios WHERE COS_MATMDO = 'MAT' ORDER BY COS_DESCR", MiConexion)
Private MiDataSetMat As New DataSet()
Private MiEnlazadorMat As New BindingSource
luego en el form_load cargo mi datagridview asi
Me.GridMateriales.DataSource = MiDataSetMat.Tables(0)
Luego en el boton agregar....
With MiAdaptadorMat
.InsertCommand = New System.Data.OleDb.OleDbCommand
.InsertCommand.Connection = MiConexion
.InsertCommand.CommandText = "INSERT INTO Precios(COS_DESCR,COS_COSTO) VALUES (@material,@costo)"
.InsertCommand.CommandType = System.Data.CommandType.Text
.InsertCommand.Parameters.Add("@material", OleDbType.VarChar).Value = txtMaterialesNuevoMat.Text
.InsertCommand.Parameters.Add("@costo", OleDbType.VarChar).Value = txtCostoEditMat.Text
End With
pero no se como agregar esos datos al datagrid.
Alguien podria darme una ayuda por favor
Gracias
CArlos
Este problema me tiene ya bastante tiempo
Con esto cargo los datos a una tabla access
Primero declaro esto
Private MiAdaptadorMat As New OleDbDataAdapter("SELECT * FROM precios WHERE COS_MATMDO = 'MAT' ORDER BY COS_DESCR", MiConexion)
Private MiDataSetMat As New DataSet()
Private MiEnlazadorMat As New BindingSource
luego en el form_load cargo mi datagridview asi
Me.GridMateriales.DataSource = MiDataSetMat.Tables(0)
Luego en el boton agregar....
With MiAdaptadorMat
.InsertCommand = New System.Data.OleDb.OleDbCommand
.InsertCommand.Connection = MiConexion
.InsertCommand.CommandText = "INSERT INTO Precios(COS_DESCR,COS_COSTO) VALUES (@material,@costo)"
.InsertCommand.CommandType = System.Data.CommandType.Text
.InsertCommand.Parameters.Add("@material", OleDbType.VarChar).Value = txtMaterialesNuevoMat.Text
.InsertCommand.Parameters.Add("@costo", OleDbType.VarChar).Value = txtCostoEditMat.Text
End With
pero no se como agregar esos datos al datagrid.
Alguien podria darme una ayuda por favor
Gracias
CArlos
Valora esta pregunta


0