Nuevo usuario ? Registrarse  |  Entrar  |  Ayuda
Preguntas y respuestas
Pregunta
Ask whatever question, you wish. Make sure you select the correct category for the question.
Responde
Like to help other, then browse through the open questions to answer their questions.
Busca
Find answer by browsing the resolved questions.
     
Buscar preguntas :
Mi cuenta



juanhdez

Preguntas abiertas Bookmark and Share

¿Agregar filas a un DataDriedView en visual basic 2008 meidante codigo?

hola tengo un datagriedview que lleno con este codigo
sql="SELECT * FROM VALES WHERE FOLIO='" & VAR & "'"
Dim cnn As New OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source= " & AppDomain.CurrentDomain.BaseDirectory & "LAB.accdb")
Dim da As New OleDb.OleDbDataAdapter(sql, cnn)
Dim cmdBuilder As New OleDb.OleDbCommandBuilder(da)
Dim dt As New DataTable("ALUMNOS")
da.Fill(dt)
Dim bs As New BindingSource
bs.DataSource = dt
BindingNavigator1.BindingSource = bs
MyDataGridView.DataSource = bs

DESPUES INTENTO AGREGARLE DOS COLUMNAS DONDE QUIERO QUE APARESCAN LOS MATERIALES Y LA CANTIDAD QUE USO ESE FOLIO EN UNA PRACTICA Y USO ESTE CODIGO

Try
conectar() 'MANDO LLAMAR LA FUNCION DE CONEXION
MyDataGridView.Columns.Add("Material", "Material")
MyDataGridView.Columns.Add("Cantidad", "Cantidad")
Dim SENTENCIA As String
SENTENCIA = "SELECT * FROM MATERIAL_MESA WHERE FOLIO='" & var & "'"
rs = conexion.Execute(SENTENCIA)
Do While Not rs.EOF
MyDataGridView.Rows.Add(rs.Fields(0).Value, _
rs.Fields(1).Value)
rs.MoveNext()
Loop
Catch ex As Exception
TextBox1.Text = ex.Message
End Try

PERO ME DA ESTE ERROR Y YA INTENTE DE TODO Y NO PUEDO
No se pueden agregar filas mediante programación a la colección de filas de DataGridView cuando el control est

325 días(s)

    Comentario(s) (0)
    Reportar abuso
   Pregunta interesante  
   Enviar por correo   
   Favoritos  
   Notifícame si hay una respuesta  
No hay comentarios por el momento     Se el primero en comentar !!!
Respuestas (1)

lperez
Mi consejo es que utilices un Dataset para llenar el DataGridView. Busca acerca de eso.

Aquí te pongo una posible solución a lo que estás buscando.

http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview.rows%28VS.80%29.aspx

Publicado hace 325 días

( 0 )
( 0 )
    Comentario(s) (0)
   Reportar abuso
No hay comentarios por el momento Se el primero en comentar en esta respuesta

Modificar tu respuesta, haz click en guardar para terminar los cambios
Titulo de la pregunta ¿Agregar filas a un DataDriedView en visual basic 2008 meidante codigo?
Tu respuesta
  |         |                            
bold  italic  underline  strike       big  small       superscript  subscript 
  Allows to add a link.
Caption :
Link URL :
( Must starts with "http://" )
Add  |   Cancel
  Allow to insert an image. Must be among the following file types - *.jpg, *.gif, *.png & *.bmp.
Image Url :  
( Image url must always starts with " http:// " )
Width : pixels
( Must not be greater than 450px. Enter 0px for no resize )
Add  |   Cancel
  Allow to insert YouTube video. Insert the video embed code.
Embed Code :
Add  |   Cancel
Número de caracteres ( Máximo - 5000 ) : 1681
Enviar un link de esta pregunta por correo electrónico
Debes introducir todos los datos.
Amigo #1 -
Amigo #2 -
Amigo #3 -
Amigo #4 -
Amigo #5 -
  Your comment on this question
  |         |                            
bold  italic  underline  strike       big  small       superscript  subscript 
  Allows to add a link.
Caption :
Link URL :
( Must starts with "http://" )
Add  |   Cancel
  Allow to insert an image. Must be among the following file types - *.jpg, *.gif, *.png & *.bmp.
Image Url :  
( Image url must always starts with " http:// " )
Width : pixels
( Must not be greater than 450px. Enter 0px for no resize )
Add  |   Cancel
  Allow to insert YouTube video. Insert the video embed code.
Embed Code :
Add  |   Cancel
Max Allowed : 5000 Characters Current Count : 0
  Your comment on this answer
  |         |                            
bold  italic  underline  strike       big  small       superscript  subscript 
  Allows to add a link.
Caption :
Link URL :
( Must starts with "http://" )
Add  |   Cancel
  Allow to insert an image. Must be among the following file types - *.jpg, *.gif, *.png & *.bmp.
Image Url :  
( Image url must always starts with " http:// " )
Width : pixels
( Must not be greater than 450px. Enter 0px for no resize )
Add  |   Cancel
  Allow to insert YouTube video. Insert the video embed code.
Embed Code :
Add  |   Cancel
Max Allowed : 5000 Characters Current Count : 0


Copyright © 2011 sowconsulting.com. Todos los derechos reservados