Imports System.Drawing Imports System.Collections Imports System.ComponentModel Imports System.Windows.Forms Imports System.Data Imports System.Data.SQLite Imports System.Diagnostics Imports System.Drawing.Printing Public Class frmAddNew Inherits System.Windows.Forms.Form 'Declaration Public Sub Print( _ ByVal ParamArray args As Object() _ ) End Sub Public way As String Function ler_bd() As Boolean Dim SQLconnect As New System.Data.SQLite.SQLiteConnection Dim SQLcommand As SQLiteCommand Dim resultado As System.Data.SQLite.SQLiteDataReader On Error GoTo erro SQLconnect.ConnectionString = "Data Source=.\MyData.db3;" SQLconnect.Open() SQLcommand = SQLconnect.CreateCommand SQLcommand.CommandText = "Select name,type from sqlite_master where type='table'" resultado = SQLcommand.ExecuteReader() TreeView.Nodes.Clear() TreeView.Nodes().Add(way) Do While resultado.Read Dim novo_nivel As TreeNode = New TreeNode(resultado("name")) TreeView.Nodes(0).Nodes.Add(novo_nivel) Loop TreeView.Nodes(0).Expand() resultado.Close() SQLconnect.Dispose() SQLcommand.Dispose() ler_bd = True Exit Function erro: MsgBox("Erro Nº " & Err.Number & vbCrLf & Err.Description) ler_bd = False End Function Private Sub TreeView_AfterSelect(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles TreeView.AfterSelect If e.Node.Level > 0 Then Dim oWatch As New Stopwatch oWatch.Start() Dim SQLconnect As New System.Data.SQLite.SQLiteConnection Dim dataSet = New DataSet() 'SQLconnect.ConnectionString = "Data Source=" & way& ";" SQLconnect.ConnectionString = "Data Source=.\MyData.db3;" SQLconnect.Open() Dim dataAdapter = New SQLiteDataAdapter("select * from " & e.Node.Text, SQLconnect) dataAdapter.Fill(dataSet, e.Node.Text) lblTableName.Text = e.Node.Text oWatch.Stop() End If End Sub Private Sub lblTableName_TextChanged(sender As System.Object, e As System.EventArgs) Handles lblTableName.TextChanged End Sub Private Sub TextBox1_TextChanged(sender As System.Object, e As System.EventArgs) Handles TextBox1.TextChanged End Sub Private Sub Principal_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Call ler_bd() End Sub Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles saveBtn.Click Dim SQLconnect As New System.Data.SQLite.SQLiteConnection Dim dataSet = New DataSet() SQLconnect.ConnectionString = "Data Source=.\MyData.db3;" SQLconnect.Open() 'How do I get this to update End Sub End Class
ADO.NET
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)