📄 datasets.vb
字号:
Option Explicit On
Option Strict On
Imports System.Data
Imports System.IO
Public Class DataSets
Private strPath As String
Private strFile As String
Private strXML As String
Private Const strIEFile As String = "\Program Files\Internet Explorer\Iexplore.exe"
Private Sub DataSets_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
strPath = Application.StartupPath
End Sub
Private Sub btnLoadNwDs_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLoadNwDs.Click
With Me.Northwind
strFile = strPath + "\Northwind.xml"
If File.Exists(strFile) Then
Try
.ReadXml(strFile)
Catch exc As Exception
Dim strMsg As String = "Row counts: Customers = "
Dim intRows As Integer
intRows = Me.Northwind.Customers.Count
strMsg += intRows.ToString + ", Orders = "
intRows = Me.Northwind.Orders.Count
strMsg += intRows.ToString + ", Order_Details = "
intRows = Me.Northwind.Order_Details.Count
strMsg += intRows.ToString
MsgBox(exc.Message + vbCrLf + strMsg)
End Try
strFile = strPath + "\Output.xml"
.WriteXml(strFile, XmlWriteMode.IgnoreSchema)
Shell("""" + strIEFile + """ " + strFile, AppWinStyle.NormalFocus)
btnSaveTables.Enabled = False
btnLoadDetails.Enabled = False
btnLoadOrders.Enabled = False
End If
End With
End Sub
Private Sub btnLoadCustomers_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLoadCustomers.Click
With Me.Northwind
strFile = strPath + "\TableCustomers.xml"
If File.Exists(strFile) Then
.Clear()
.ReadXml(strFile)
strFile = strPath + "\Output.xml"
.WriteXml(strFile, XmlWriteMode.IgnoreSchema)
Shell("""" + strIEFile + """ " + strFile, AppWinStyle.NormalFocus)
btnLoadOrders.Enabled = True
End If
End With
End Sub
Private Sub btnLoadOrders_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLoadOrders.Click
With Me.Northwind
strFile = strPath + "\TableOrders.xml"
If File.Exists(strFile) Then
.ReadXml(strFile)
strFile = strPath + "\Output.xml"
.WriteXml(strFile, XmlWriteMode.IgnoreSchema)
Shell("""" + strIEFile + """ " + strFile, AppWinStyle.NormalFocus)
btnLoadDetails.Enabled = True
End If
End With
End Sub
Private Sub btnLoadDetails_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLoadDetails.Click
With Me.Northwind
strFile = strPath + "\TableDetails.xml"
If File.Exists(strFile) Then
.ReadXml(strFile)
strFile = strPath + "\Output.xml"
.WriteXml(strFile, XmlWriteMode.IgnoreSchema)
Shell("""" + strIEFile + """ " + strFile, AppWinStyle.NormalFocus)
btnSaveTables.Enabled = True
End If
End With
End Sub
Private Sub btnShowNwXsd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnShowNwXsd.Click
strFile = strPath + "\Northwind.xsd"
If File.Exists(strFile) Then
Shell("""" + strIEFile + """ " + strFile, AppWinStyle.NormalFocus)
End If
End Sub
Private Sub btnSaveTables_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSaveTables.Click
With Me.Northwind
strFile = strPath + "\OutputCustomers.xml"
.Customers.WriteXml(strFile, XmlWriteMode.IgnoreSchema)
strFile = strPath + "\OutputOrders.xml"
.Customers.WriteXml(strFile, XmlWriteMode.IgnoreSchema)
strFile = strPath + "\OutputDetails.xml"
.Customers.WriteXml(strFile, XmlWriteMode.IgnoreSchema)
End With
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -