Files
Lehrlingsparcours/_archiv/LP/.svn/pristine/cd/cda0ab5e7810eba8acd0bf47fddae7a859507cd2.svn-base
2019-12-21 10:58:30 +01:00

69 lines
2.7 KiB
Plaintext

Imports System.Data.SQLite
Public Class FrmSpaltenTitel
Private Sub FrmSpaltenTitel_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim selectFirst As Boolean = False
Dim SQLconnect As New SQLite.SQLiteConnection()
Dim SQLcommand As SQLiteCommand
SQLconnect.ConnectionString = Globals.Datenbank
SQLconnect.Open()
SQLcommand = SQLconnect.CreateCommand
Dim SchemaTable = SQLconnect.GetSchema(SQLiteMetaDataCollectionNames.Tables)
Me.ListBox1.Items.Clear()
For int As Integer = 0 To SchemaTable.Rows.Count - 1
If SchemaTable.Rows(int)!TABLE_TYPE.ToString = "table" Then
Me.ListBox1.Items.Add(SchemaTable.Rows(int)!TABLE_NAME.ToString())
selectFirst = True
End If
Next
SQLcommand.Dispose()
SQLconnect.Close()
End Sub
Private Sub ListBox1_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListBox1.DoubleClick
Dim selectFirst As Boolean = False
Dim ds As New DataSet
Dim SQLconnect As New SQLite.SQLiteConnection()
SQLconnect.ConnectionString = Globals.Datenbank
SQLconnect.Open()
Dim da As New SQLiteDataAdapter("", SQLconnect)
Dim sqlcmd As New SQLiteCommand
sqlcmd.Connection = SQLconnect
sqlcmd.CommandType = CommandType.Text
sqlcmd.CommandText = "Select * from " + ListBox1.SelectedItem
da.SelectCommand = sqlcmd
da.Fill(ds, "Daten")
sqlcmd.Dispose()
SQLconnect.Close()
Dim lpdataset As New LPDataSet
Dim lpspaltenadapter = New LPDataSetTableAdapters.spaltenTableAdapter
Dim dbkey As New clsdbkey
Dim i As Integer = 0
Dim spaltenrow As LPDataSet.spaltenRow
For Each c As DataColumn In ds.Tables(0).Columns
spaltenrow = lpdataset.spalten.NewRow
spaltenrow.eintragnr = dbkey.Get_NewKey("Spalten")
spaltenrow.tabelle = ListBox1.SelectedItem
spaltenrow.tabellenspalte = c.Caption
spaltenrow.spalte = c.Caption
spaltenrow.alsHacken = False
spaltenrow.Breite = 0
spaltenrow.Reihenfolge = 0
spaltenrow.tiptext = ""
spaltenrow.aktiv = True
spaltenrow.erstellt_am = Now
spaltenrow.mutierer = 1
spaltenrow.mutiert_am = Now
spaltenrow.mandantnr = 1
spaltenrow.NumberFormat = ""
spaltenrow._Readonly = False
lpdataset.spalten.AddspaltenRow(spaltenrow)
lpspaltenadapter.Update(lpdataset.spalten)
Next
End Sub
End Class