📄 datatables.vb
字号:
Public Class frmDataSets
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
Me.daCustomers.Fill(Me.dsMaster1.CustomerList)
Me.daOrders.Fill(Me.dsMaster1.OrderTotals)
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
Friend WithEvents cnNorthwind As System.Data.SqlClient.SqlConnection
Friend WithEvents cmdSelectCustomers As System.Data.SqlClient.SqlCommand
Friend WithEvents daCustomers As System.Data.SqlClient.SqlDataAdapter
Friend WithEvents cmdSelectOrders As System.Data.SqlClient.SqlCommand
Friend WithEvents cmdSelectEmployees As System.Data.SqlClient.SqlCommand
Friend WithEvents daEmployees As System.Data.SqlClient.SqlDataAdapter
Friend WithEvents lblEmployees As System.Windows.Forms.Label
Friend WithEvents lblClients As System.Windows.Forms.Label
Friend WithEvents lblOrders As System.Windows.Forms.Label
Friend WithEvents dgOrders As System.Windows.Forms.DataGrid
Friend WithEvents lbEmployees As System.Windows.Forms.ListBox
Friend WithEvents lbClients As System.Windows.Forms.ListBox
Friend WithEvents daOrders As System.Data.SqlClient.SqlDataAdapter
Friend WithEvents dsUntyped As System.Data.DataSet
Dim dsEmployees As New System.Data.DataSet("dsEmployees")
Friend WithEvents dtMaster As System.Data.DataTable
Friend WithEvents MasterID As System.Data.DataColumn
Friend WithEvents MasterValue As System.Data.DataColumn
Friend WithEvents dtChild As System.Data.DataTable
Friend WithEvents ChildID As System.Data.DataColumn
Friend WithEvents MasterLink As System.Data.DataColumn
Friend WithEvents ChildValue As System.Data.DataColumn
Friend WithEvents btnDataSet As System.Windows.Forms.Button
Friend WithEvents btnCalculate As System.Windows.Forms.Button
Friend WithEvents btnAddRow As System.Windows.Forms.Button
Friend WithEvents btnVersion As System.Windows.Forms.Button
Friend WithEvents btnSchema As System.Windows.Forms.Button
Friend WithEvents btnForeign As System.Windows.Forms.Button
Friend WithEvents btnUnique As System.Windows.Forms.Button
Friend WithEvents btnSelect As System.Windows.Forms.Button
'Required by the Windows Form Designer
Private components As System.ComponentModel.Container
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents dsMaster1 As DataSets.dsMaster
Friend WithEvents btnTable As System.Windows.Forms.Button
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.btnAddRow = New System.Windows.Forms.Button()
Me.dtChild = New System.Data.DataTable()
Me.ChildID = New System.Data.DataColumn()
Me.MasterLink = New System.Data.DataColumn()
Me.ChildValue = New System.Data.DataColumn()
Me.btnCalculate = New System.Windows.Forms.Button()
Me.btnUnique = New System.Windows.Forms.Button()
Me.btnVersion = New System.Windows.Forms.Button()
Me.btnSchema = New System.Windows.Forms.Button()
Me.daEmployees = New System.Data.SqlClient.SqlDataAdapter()
Me.cmdSelectEmployees = New System.Data.SqlClient.SqlCommand()
Me.cnNorthwind = New System.Data.SqlClient.SqlConnection()
Me.btnForeign = New System.Windows.Forms.Button()
Me.lbClients = New System.Windows.Forms.ListBox()
Me.cmdSelectCustomers = New System.Data.SqlClient.SqlCommand()
Me.daCustomers = New System.Data.SqlClient.SqlDataAdapter()
Me.daOrders = New System.Data.SqlClient.SqlDataAdapter()
Me.cmdSelectOrders = New System.Data.SqlClient.SqlCommand()
Me.lblOrders = New System.Windows.Forms.Label()
Me.btnSelect = New System.Windows.Forms.Button()
Me.MasterID = New System.Data.DataColumn()
Me.dsUntyped = New System.Data.DataSet()
Me.dtMaster = New System.Data.DataTable()
Me.MasterValue = New System.Data.DataColumn()
Me.btnDataSet = New System.Windows.Forms.Button()
Me.lbEmployees = New System.Windows.Forms.ListBox()
Me.dgOrders = New System.Windows.Forms.DataGrid()
Me.lblEmployees = New System.Windows.Forms.Label()
Me.lblClients = New System.Windows.Forms.Label()
Me.dsMaster1 = New DataSets.dsMaster()
Me.btnTable = New System.Windows.Forms.Button()
CType(Me.dtChild, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.dsUntyped, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.dtMaster, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.dgOrders, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.dsMaster1, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'btnAddRow
'
Me.btnAddRow.Location = New System.Drawing.Point(416, 120)
Me.btnAddRow.Name = "btnAddRow"
Me.btnAddRow.Size = New System.Drawing.Size(96, 23)
Me.btnAddRow.TabIndex = 4
Me.btnAddRow.Text = "Add DataRow"
'
'dtChild
'
Me.dtChild.Columns.AddRange(New System.Data.DataColumn() {Me.ChildID, Me.MasterLink, Me.ChildValue})
Me.dtChild.TableName = "dtChild"
'
'ChildID
'
Me.ChildID.AllowDBNull = False
Me.ChildID.AutoIncrement = True
Me.ChildID.Caption = "ChildID"
Me.ChildID.ColumnName = "ChildID"
Me.ChildID.DataType = GetType(System.Int32)
'
'MasterLink
'
Me.MasterLink.AllowDBNull = False
Me.MasterLink.Caption = "MasterLink"
Me.MasterLink.ColumnName = "MasterLink"
Me.MasterLink.DataType = GetType(System.Int32)
'
'ChildValue
'
Me.ChildValue.Caption = "ChildValue"
Me.ChildValue.ColumnName = "ChildValue"
'
'btnCalculate
'
Me.btnCalculate.Location = New System.Drawing.Point(416, 88)
Me.btnCalculate.Name = "btnCalculate"
Me.btnCalculate.Size = New System.Drawing.Size(96, 24)
Me.btnCalculate.TabIndex = 4
Me.btnCalculate.Text = "Calculate"
'
'btnUnique
'
Me.btnUnique.Location = New System.Drawing.Point(416, 248)
Me.btnUnique.Name = "btnUnique"
Me.btnUnique.Size = New System.Drawing.Size(96, 23)
Me.btnUnique.TabIndex = 4
Me.btnUnique.Text = "Unique"
'
'btnVersion
'
Me.btnVersion.Location = New System.Drawing.Point(416, 152)
Me.btnVersion.Name = "btnVersion"
Me.btnVersion.Size = New System.Drawing.Size(96, 23)
Me.btnVersion.TabIndex = 4
Me.btnVersion.Text = "Row Version"
'
'btnSchema
'
Me.btnSchema.Location = New System.Drawing.Point(416, 184)
Me.btnSchema.Name = "btnSchema"
Me.btnSchema.Size = New System.Drawing.Size(96, 23)
Me.btnSchema.TabIndex = 4
Me.btnSchema.Text = "FillSchema"
'
'daEmployees
'
Me.daEmployees.SelectCommand = Me.cmdSelectEmployees
Me.daEmployees.TableMappings.AddRange(New System.Data.Common.DataTableMapping() {New System.Data.Common.DataTableMapping("Table", "EmployeeList", New System.Data.Common.DataColumnMapping() {New System.Data.Common.DataColumnMapping("EmployeeID", "EmployeeID"), New System.Data.Common.DataColumnMapping("FirstName", "FirstName"), New System.Data.Common.DataColumnMapping("LastName", "LastName")})})
'
'cmdSelectEmployees
'
Me.cmdSelectEmployees.CommandText = "SELECT EmployeeID, FirstName, LastName FROM EmployeeList"
Me.cmdSelectEmployees.Connection = Me.cnNorthwind
'
'cnNorthwind
'
Me.cnNorthwind.ConnectionString = "data source=localhost;initial catalog=nwind;integrated security=SSPI;persist " & _
"security info=False;packet size=4096"
'
'btnForeign
'
Me.btnForeign.Location = New System.Drawing.Point(416, 216)
Me.btnForeign.Name = "btnForeign"
Me.btnForeign.Size = New System.Drawing.Size(96, 23)
Me.btnForeign.TabIndex = 4
Me.btnForeign.Text = "Foreign Key"
'
'lbClients
'
Me.lbClients.DataSource = Me.dsMaster1.CustomerList
Me.lbClients.DisplayMember = "CompanyName"
Me.lbClients.Location = New System.Drawing.Point(200, 24)
Me.lbClients.Name = "lbClients"
Me.lbClients.Size = New System.Drawing.Size(200, 95)
Me.lbClients.TabIndex = 2
Me.lbClients.ValueMember = "CustomerID"
'
'cmdSelectCustomers
'
Me.cmdSelectCustomers.CommandText = "SELECT CustomerID, CompanyName, City, Country, PostalCode, Region FROM CustomerLi" & _
"st"
Me.cmdSelectCustomers.Connection = Me.cnNorthwind
'
'daCustomers
'
Me.daCustomers.SelectCommand = Me.cmdSelectCustomers
Me.daCustomers.TableMappings.AddRange(New System.Data.Common.DataTableMapping() {New System.Data.Common.DataTableMapping("Table", "CustomerList", New System.Data.Common.DataColumnMapping() {New System.Data.Common.DataColumnMapping("CustomerID", "CustomerID"), New System.Data.Common.DataColumnMapping("CompanyName", "CompanyName"), New System.Data.Common.DataColumnMapping("City", "City"), New System.Data.Common.DataColumnMapping("Country", "Country"), New System.Data.Common.DataColumnMapping("PostalCode", "PostalCode"), New System.Data.Common.DataColumnMapping("Region", "Region")})})
'
'daOrders
'
Me.daOrders.SelectCommand = Me.cmdSelectOrders
Me.daOrders.TableMappings.AddRange(New System.Data.Common.DataTableMapping() {New System.Data.Common.DataTableMapping("Table", "OrderTotals", New System.Data.Common.DataColumnMapping() {New System.Data.Common.DataColumnMapping("CustomerID", "CustomerID"), New System.Data.Common.DataColumnMapping("OrderID", "OrderID"), New System.Data.Common.DataColumnMapping("OrderDate", "OrderDate"), New System.Data.Common.DataColumnMapping("Subtotal", "Subtotal")})})
'
'cmdSelectOrders
'
Me.cmdSelectOrders.CommandText = "SELECT EmployeeID, CustomerID, OrderID, OrderDate, Subtotal FROM OrderTotals"
Me.cmdSelectOrders.Connection = Me.cnNorthwind
'
'lblOrders
'
Me.lblOrders.AutoSize = True
Me.lblOrders.Font = New System.Drawing.Font("Microsoft Sans Serif", 8.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.lblOrders.Location = New System.Drawing.Point(8, 136)
Me.lblOrders.Name = "lblOrders"
Me.lblOrders.Size = New System.Drawing.Size(43, 13)
Me.lblOrders.TabIndex = 0
Me.lblOrders.Text = "Orders:"
'
'btnSelect
'
Me.btnSelect.Location = New System.Drawing.Point(416, 280)
Me.btnSelect.Name = "btnSelect"
Me.btnSelect.Size = New System.Drawing.Size(96, 23)
Me.btnSelect.TabIndex = 4
Me.btnSelect.Text = "Select"
'
'MasterID
'
Me.MasterID.AllowDBNull = False
Me.MasterID.AutoIncrement = True
Me.MasterID.Caption = "MasterID"
Me.MasterID.ColumnName = "MasterID"
Me.MasterID.DataType = GetType(System.Int32)
'
'dsUntyped
'
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -