⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 customer.vb

📁 vb.net MCP课程的英文讲义,70-310课程,值得一读
💻 VB
字号:
Imports System.Data.SqlClient
Imports System.EnterpriseServices
Imports System.Runtime.InteropServices

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

<Transaction(TransactionOption.Required), ConstructionEnabled(True), ClassInterface(ClassInterfaceType.None)> _
Public Class Customer
    Inherits ServicedComponent
    Implements ICustomer

    Private connString As String

    Public Function LogOn(ByVal Email As String, ByVal Password As String) As DataSet Implements CustomerComponent.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()

            ContextUtil.SetComplete()
            Return datCustomer
        Catch ex As Exception
            ContextUtil.SetAbort()
            Throw (ex)
        End Try
    End Function

    Public Overrides Sub Construct(ByVal s As String)
        connString = s
    End Sub
End Class

⌨️ 快捷键说明

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