Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
Invio Dati Access - Form1.vb

Form1.vb

Caricato da:
Scarica il programma completo

  1. Imports System
  2. Imports System.Drawing
  3. Imports System.Collections
  4. Imports System.ComponentModel
  5. Imports System.Windows.Forms
  6. Imports System.Data
  7. Imports System.Data.OleDb
  8. Imports System.Threading
  9.  
  10.  
  11. Namespace WindowsApplication12
  12.    '/ <summary>
  13.    '/ Descrizione di riepilogo per Form1.
  14.    '/ </summary>
  15.    
  16.    Public Class Form1
  17.       Inherits System.Windows.Forms.Form
  18.       Private WithEvents button1 As System.Windows.Forms.Button
  19.       Private WithEvents button2 As System.Windows.Forms.Button
  20.       Private lol As System.Windows.Forms.TextBox
  21.       Private asd As System.Windows.Forms.TextBox
  22.       Private label1 As System.Windows.Forms.Label
  23.       Private label2 As System.Windows.Forms.Label
  24.       '/ <summary>
  25.       '/ Variabile di progettazione necessaria.
  26.       '/ </summary>
  27.       Private components As System.ComponentModel.Container = Nothing
  28.      
  29.      
  30.       Public Sub New()
  31.          '
  32.          ' Necessario per il supporto di Progettazione Windows Form
  33.          '
  34.          InitializeComponent()
  35.       End Sub 'New
  36.        
  37.       '
  38.       ' TODO: aggiungere il codice del costruttore dopo la chiamata a InitializeComponent
  39.       '
  40.      
  41.       '/ <summary>
  42.       '/ Pulire le risorse in uso.
  43.       '/ </summary>
  44.       Protected Overrides Sub Dispose(disposing As Boolean)
  45.          If disposing Then
  46.             If Not (components Is Nothing) Then
  47.                components.Dispose()
  48.             End If
  49.          End If
  50.          MyBase.Dispose(disposing)
  51.       End Sub 'Dispose
  52.      
  53.       Public Sub InserisciDati()
  54.          
  55.          Dim nick As String = lol.Text
  56.          Dim nicks As String = asd.Text
  57.          Dim conn As New OleDbConnection()
  58.          conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Data source= " + System.Environment.CurrentDirectory + "\lol.mdb"
  59.          Try
  60.             conn.Open()
  61.             Dim sql As String = "INSERT INTO rubrica(nome,cognome) VALUES('" + nick + "','" + nicks + "');"
  62.             Dim cmd As New OleDbCommand(sql, conn)
  63.             Dim dr As OleDbDataReader = cmd.ExecuteReader()
  64.          
  65.          
  66.          
  67.          Catch Else
  68.          Finally
  69.             conn.Close()
  70.             CreaTabella()
  71.          End Try
  72.       End Sub 'InserisciDati
  73.      
  74.       Public Shared Sub CreaTabella()
  75.          Dim conn As New OleDbConnection()
  76.          conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Data source= " + System.Environment.CurrentDirectory + "\lol.mdb"
  77.          Try
  78.             conn.Open()
  79.             Dim sql As String = "CREATE TABLE rubrica (nome char(20),cognome char(80));"
  80.             Dim cmd As New OleDbCommand(sql, conn)
  81.             Dim dr As OleDbDataReader = cmd.ExecuteReader()
  82.          Catch Else
  83.          Finally
  84.             conn.Close()
  85.          End Try
  86.       End Sub 'CreaTabella
  87.       #Region "Codice generato da Progettazione Windows Form"
  88.      
  89.       '/ <summary>
  90.       '/ Metodo necessario per il supporto della finestra di progettazione. Non modificare
  91.       '/ il contenuto del metodo con l'editor di codice.
  92.       '/ </summary>
  93.       Private Sub InitializeComponent()
  94.          Me.lol = New System.Windows.Forms.TextBox()
  95.          Me.asd = New System.Windows.Forms.TextBox()
  96.          Me.button1 = New System.Windows.Forms.Button()
  97.          Me.button2 = New System.Windows.Forms.Button()
  98.          Me.label1 = New System.Windows.Forms.Label()
  99.          Me.label2 = New System.Windows.Forms.Label()
  100.          Me.SuspendLayout()
  101.          '
  102.          ' lol
  103.          '
  104.          Me.lol.Location = New System.Drawing.Point(24, 32)
  105.          Me.lol.Name = "lol"
  106.          Me.lol.Size = New System.Drawing.Size(96, 20)
  107.          Me.lol.TabIndex = 0
  108.          Me.lol.Text = ""
  109.          '
  110.          ' asd
  111.          '
  112.          Me.asd.Location = New System.Drawing.Point(168, 32)
  113.          Me.asd.Name = "asd"
  114.          Me.asd.Size = New System.Drawing.Size(104, 20)
  115.          Me.asd.TabIndex = 1
  116.          Me.asd.Text = ""
  117.          '
  118.          ' button1
  119.          '
  120.          Me.button1.Location = New System.Drawing.Point(16, 72)
  121.          Me.button1.Name = "button1"
  122.          Me.button1.Size = New System.Drawing.Size(120, 48)
  123.          Me.button1.TabIndex = 2
  124.          Me.button1.Text = "CReaTaBeLLa"
  125.          '
  126.          ' button2
  127.          '
  128.          Me.button2.Location = New System.Drawing.Point(160, 72)
  129.          Me.button2.Name = "button2"
  130.          Me.button2.Size = New System.Drawing.Size(120, 48)
  131.          Me.button2.TabIndex = 3
  132.          Me.button2.Text = "InSeRiSCi DaTi"
  133.          '
  134.          ' label1
  135.          '
  136.          Me.label1.Location = New System.Drawing.Point(24, 8)
  137.          Me.label1.Name = "label1"
  138.          Me.label1.Size = New System.Drawing.Size(96, 16)
  139.          Me.label1.TabIndex = 4
  140.          Me.label1.Text = "NoMe"
  141.          '
  142.          ' label2
  143.          '
  144.          Me.label2.Location = New System.Drawing.Point(168, 8)
  145.          Me.label2.Name = "label2"
  146.          Me.label2.Size = New System.Drawing.Size(96, 16)
  147.          Me.label2.TabIndex = 5
  148.          Me.label2.Text = "CoGnoMe"
  149.          '
  150.          ' Form1
  151.          '
  152.          Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
  153.          Me.ClientSize = New System.Drawing.Size(296, 142)
  154.          Me.Controls.Add(label2)
  155.          Me.Controls.Add(label1)
  156.          Me.Controls.Add(button2)
  157.          Me.Controls.Add(button1)
  158.          Me.Controls.Add(asd)
  159.          Me.Controls.Add(lol)
  160.          Me.Name = "Form1"
  161.          Me.Text = "InVio DaTi Db ACCeSS By SaTaNa"
  162.          Me.ResumeLayout(False)
  163.       End Sub 'InitializeComponent
  164.       #End Region
  165.      
  166.      
  167.       '/ <summary>
  168.       '/ Il punto di ingresso principale dell'applicazione.
  169.       '/ </summary>
  170.       <STAThread()>  _
  171.       Shared Sub Main()
  172.          Application.Run(New Form1())
  173.       End Sub 'Main
  174.      
  175.      
  176.       Private Sub Form1_Load(sender As Object, e As System.EventArgs) Handles MyBase.Load
  177.       End Sub 'Form1_Load
  178.      
  179.      
  180.      
  181.       Private Sub button1_Click(sender As Object, e As System.EventArgs) Handles button1.Click
  182.          Dim f As New Thread(New ThreadStart(AddressOf CreaTabella))
  183.          f.Start()
  184.       End Sub 'button1_Click
  185.      
  186.      
  187.       Private Sub button2_Click(sender As Object, e As System.EventArgs) Handles button2.Click
  188.          Dim t As New Thread(New ThreadStart(AddressOf InserisciDati))
  189.          t.Start()
  190.       End Sub 'button2_Click
  191.    End Class 'Form1
  192. End Namespace 'WindowsApplication12