Torna al Thread

Public Class Form1 ... Private Sub COM1_DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles COM1.DataReceived Dim codice As String = Replace(COM1.ReadExisting, vbCrLf, "") HandleData(codice) End Sub Private Sub HandleData(ByVal SerData As String) Dim conn As New SqlConnection, cm As New SqlCommand Dim dr As SqlDataReader ncard = SerData Try conn.ConnectionString = "Server=.\DEVEL; Database=DB; Integrated Security=SSPI" conn.Open() cm.CommandText = "SELECT Nome, Cognome FROM Anagrafiche WHERE nCard LIKE '%" & SerData & "'" cm.Connection = conn dr = cm.ExecuteReader() If dr.HasRows Then dr.Read() 'nome e cognome sono dichiarate globali e usate nell'evento Form2_Load nome = dr.Item("nome") cognome = dr.Item("Cognome") Else MsgBox("CARD NON REGISTRATA") End If Form2.Show() Catch ex as Exception MsgBox("ERRORE GENERALE: " & ex.Message) Finally conn.Close() conn.Dispose() dr.Dispose() cm.Dispose() End Try End Sub ... End Class
Copyright © dotNetHell.it 2002-2024
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5