customer.vb

来自「介绍vb.net的一本很好的英文资料,深入浅出,值得一读」· VB 代码 · 共 38 行

VB
38
字号
Imports System.Data.SqlClient


Public Interface ICustomer
    Function LogOn(ByVal Email As String, ByVal Password As String) As DataSet
End Interface

Public Class Customer
    Implements ICustomer

    Private connString As String

    Public Function LogOn(ByVal Email As String, ByVal Password As String) As DataSet Implements ICustomer.Logon
        Try
            Dim conn As New SqlConnection(connString)
            Dim adaptSQL As New SqlDataAdapter("Select CustomerID, FirstName, LastName, CompanyName, Address from Customers where Email = '" & Email & "' and Pword = '" & Password & "'", conn)
            Dim datCustomer As New DataSet()
            'open the connection and get the data
            conn.Open()
            adaptSQL.Fill(datCustomer)

            'check if machine data was found, and update Last_LogOn datetime value
            If datCustomer.Tables(0).Rows.Count > 0 Then
                Dim cmd As New SqlCommand("Update Customers Set Last_Logon = GetDate() Where CustomerID = " & datCustomer.Tables(0).Rows(0)("CustomerID"), conn)
                cmd.ExecuteNonQuery()
            End If

            conn.Close()

            Return datCustomer
        Catch ex As Exception
            Throw (ex)
        End Try
    End Function

End Class

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?