Ver Mensaje Individual
  #2 (permalink)  
Antiguo 24/02/2011, 09:18
Avatar de Aquaventus
Aquaventus
 
Fecha de Ingreso: junio-2010
Ubicación: Lima-Peru , En el alba de la naturaleza
Mensajes: 2.105
Antigüedad: 13 años, 10 meses
Puntos: 267
Respuesta: Recorrer dataGrid

Hola proteus8 puedes hacer algo como esto :

Código vb.net:
Ver original
  1. Public Sub metodo()
  2.         'creas las variables segun la cantidad de campos
  3.         'que tenga tu consulta
  4.         Dim campo1, campo2, campo3, campo4, campo5 As String
  5.  
  6.  
  7.         For f As Integer = 0 To DataGrid1.Rows.Count - 1 'X filas
  8.             For c As Integer = 0 To DataGrid1.Columns.Count - 1 'Asumamos 5 campos
  9.                 If c = 0 Then
  10.                     campo1 = DataGrid1.Rows(f).Cells(c).Value
  11.                 ElseIf c = 1 Then
  12.                     campo2 = DataGrid1.Rows(f).Cells(c).Value
  13.                 ElseIf c = 2 Then
  14.                     campo3 = DataGrid1.Rows(f).Cells(c).Value
  15.                 ElseIf c = 3 Then
  16.                     campo4 = DataGrid1.Rows(f).Cells(c).Value
  17.                 Else
  18.                     campo5 = DataGrid1.Rows(f).Cells(c).Value
  19.                 End If
  20.             Next
  21.             Dim mySql As String
  22.             cnnl = New SQLiteConnection("Data Source=\BACKUP\BD\CLAS_MOBILE.db;Version=3;")
  23.             cnnl.Open()
  24.             mySql = "INSERT INTO TUTABLA VALUES('" + campo1 + "','" + campo2 + "','" + campo3 + "','" + campo4 + "','" + campo5 + "')"
  25.             insertarConsulta(mySql)
  26.         Next
  27.     End Sub
  28.  
  29.      sub insertarConsulta(ByVal mySql As String)
  30.         Try
  31.             Ada = New SQLiteDataAdapter(mySql, cnnl)
  32.             '...TU CODE
  33.         Catch ex As Exception
  34.             MessageBox.Show(ex.Message, "Error")
  35.         End Try
  36.     End Sub

Espero te sea de utilidad. Saludos!
__________________
Internet es tener todo el conocimiento global a tu disposición.
Desarrollo de Software - Ejemplos .Net