Datagridview
HejVB .net. Følgende kode anvender datagridview til at vise resultatet fra en sql-database MEN den viser det i en lang streng.
Er det muligt i stedet at få vist hver (opg + hvem) i en ny linie a la:
Opg1, Hvem1
Opg2, Hvem2 etc
Private Sub HentToDo()
Dim Connection As New SqlConnection(Conn)
Connection.Open()
Dim Dato As DateTime = DateTimePicker1.Value.ToShortDateString
'To Do
Try
Dim ds2 As New DataSet
Dim strSQL As String = "Opg1, Hvem1, Opg2, Hvem2, Opg3, Hvem3, Opg4, Hvem4, Opg5, Hvem5, Opg6, Hvem6, Opg7, Hvem7, Opg8, Hvem8, Opg9, Hvem9, Opg10, Hvem10, Opg11, Hvem11, Opg12, Hvem12, Opg13, Hvem13, Opg14, Hvem14, Opg15, Hvem15 FROM Vagthold WHERE Dato = @Dato"
adapter = New SqlDataAdapter(strSQL, Connection)
adapter.Fill(ds2)
DataGridView2.DataSource = ds2.Tables(0)
Catch ex As Exception
MsgBox(ex.ToString)
End Try
Connection.Close()
End Sub