KingLM97
Lieutenant
- Registriert
- Mai 2012
- Beiträge
- 908
Ich lade eine MySQL Tabelle mit sehr vielen leeren Spalten, doch ich habe das Problem, dass ich die leeren Spalten einfach nicht aussortiert bekomme.
Ich habe es bisher mit einem Array und einer ArrayList probiert. Keines von beidem führte zum erfolg. Kann mir da jemand helfen? Ich bin noch relativ neu in VB. Danke im Vorraus.
Code:
Imports MySql.Data.MySqlClient
Public Class Form1
Public servername As String
Public datenbasis As String
Public ID As String
Public pw As String
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles ButtonDaten.Click
Einstellungen.Show()
End Sub
Private Sub ButtonVerbinden_Click(sender As Object, e As EventArgs) Handles ButtonVerbinden.Click
Dim con As New MySqlConnection
Dim cmd As New MySqlCommand
Dim ada As MySqlDataAdapter
Dim table As DataTable
Try
con.ConnectionString =
"Server=" + servername + ";" +
"Database=" + datenbasis + ";" +
"Uid=" + ID + ";" +
"Pwd=" + pw + ";"
con.Open()
Catch ex As MySqlException
MsgBox(ex.Message)
End Try
'Tabelle anzeigen
Try
cmd.Connection = con
ada = New MySqlDataAdapter("select * from paintball.auftrag", con)
table = New DataTable
ada.Fill(table)
DataGridView1.DataSource = table
con.Close()
Catch ex As Exception
MsgBox(ex.Message)
End Try
Dim dts As DataTable = DataGridView1.DataSource
Dim array As New ArrayList()
MsgBox(dts.Columns.Count)
MsgBox(dts.Rows.Count)
For i2 As Integer = 0 To dts.Columns.Count - 1
array.Clear()
For i As Integer = 0 To dts.Rows.Count - 1
Dim test As String = DataGridView1.Rows(i).Cells(i2).Value.ToString
If Not test = String.Empty Then
Console.WriteLine(test)
End If
array.Add(test)
Next
Next
End Sub
End Class
Ich habe es bisher mit einem Array und einer ArrayList probiert. Keines von beidem führte zum erfolg. Kann mir da jemand helfen? Ich bin noch relativ neu in VB. Danke im Vorraus.