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

📄 form1.vb

📁 数据库学习的绝好例子简单的数据库经典入门
💻 VB
字号:
Imports System.Data

Public Class Form1
    'Private variables and objects
    Private strCompany As String = "Wrox"
    Private strApplication As String = "Time Tracker SQL"

    Private objProjects As WroxBusinessLogic.WBLProjects

    Private objDataSet As Data.DataSet
    Private objProjectsDS As Data.DataSet

    Private Sub Form1_Load(ByVal sender As System.Object, _
        ByVal e As System.EventArgs) Handles MyBase.Load

        'Initialize a new instance of the business logic component
        Using objProjects As New WroxBusinessLogic.WBLProjects( _
            strCompany, strApplication)

            Try
                'Get all projects in a DataSet object
                objProjectsDS = objProjects.GetProjects()

                'Bind ListBox control
                ListBox1.DataSource = objProjectsDS.Tables("Projects")
                ListBox1.DisplayMember = "ProjectName"
                ListBox1.ValueMember = "ProjectID"

            Catch ExceptionErr As Exception
                MessageBox.Show(ExceptionErr.Message, "Exercise 1")
            End Try
        End Using
    End Sub

    Private Sub ListBox1_Click(ByVal sender As Object, _
        ByVal e As System.EventArgs) Handles ListBox1.Click

        'Initialize a new instance of the business logic component
        Using objProjects As New WroxBusinessLogic.WBLProjects( _
            strCompany, strApplication)

            Try
                'Get the specific project selected in the ListView control
                objDataSet = objProjects.GetProject( _
                    New Guid(ListBox1.SelectedValue.ToString))

                txtProjectDescription.Text = _
                    objDataSet.Tables("Project").Rows(0).Item( _
                    "ProjectDescription")

            Catch ExceptionErr As Exception
                MessageBox.Show(ExceptionErr.Message, "Exercise 1")
            End Try
        End Using
    End Sub
End Class

⌨️ 快捷键说明

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