Ver Mensaje Individual
  #2 (permalink)  
Antiguo 16/09/2011, 14:18
dvp28
 
Fecha de Ingreso: junio-2010
Mensajes: 5
Antigüedad: 13 años, 9 meses
Puntos: 1
Respuesta: Pasar dato de un Datagridview a otro y ejecutar una consulta

solo te dejo el codigo(ya que era tu tarea hacerlo), deberias entender:
Código VB:
Ver original
  1. Dim fhd As New Solucion_varios_HelpDesk
  2. Dim x As Integer = 0
  3. Dim codigos As String = ""
  4.  
  5. Do While x < DataGrid_Consulta.RowCount
  6. If Me.DataGrid_Consulta.Rows(x).Cells(0).Value = True Then
  7. codigos += "'" + DataGrid_Consulta.Rows(x).Cells(1).Value + "',"
  8. End If
  9. x = x + 1
  10. Loop
  11.  
  12. fhd.generar(Strings.Left(codigos, codigos.Length - 1))
  13.  
  14. fhd.Show()
  15.  
  16.  
  17.  
  18. Public Sub generar(ByVal i As String)
  19.  
  20. Me.conexion.Close()
  21. Me.conexion.ConnectionString = "Data Source=192.168.1.200,1433;" & "Initial Catalog=Develop;" & "User Id=Help_Desk;" & "Password=rtc-2011;"
  22. query = ("SELECT HI.Id_case, HU.User_name, HI.Issue_Name, HI.Issue_Description, HI.Observation, HI.Request_date, HI.PC_ID, HU.Mail FROM HelpDesk_Issues AS HI INNER JOIN HelpDesk_Users AS HU ON HI.User_Id = HU.User_Id WHERE hi.Id_case in (" & i & ") and hi.Status = 3")
  23.  
  24. comando = New SqlClient.SqlCommand
  25. comando.Connection = conexion
  26. comando.CommandText = query
  27.  
  28. Try
  29. conexion.Open()
  30. Dim ds As New DataSet
  31. Dim da As New SqlDataAdapter(query, Me.conexion)
  32. da.Fill(ds, "HelpDesk_Issues")
  33. DataGridView_varios.DataSource = ds.Tables("HelpDesk_Issues")
  34. conexion.Close()
  35.  
  36. Catch ex As Exception
  37. MsgBox("Ha habido problemas al intentar establecer conexion" & ex.Message, MsgBoxStyle.Critical)
  38. Finally
  39. End Try
  40.  
  41. End Sub


Saludos.