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

📄 errors.frm

📁 VB6数据库开发指南》的配套源程序
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "Form1"
   ClientHeight    =   4230
   ClientLeft      =   1095
   ClientTop       =   1515
   ClientWidth     =   6720
   LinkTopic       =   "Form1"
   PaletteMode     =   1  'UseZOrder
   ScaleHeight     =   4230
   ScaleWidth      =   6720
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Private Sub Form_Load()
    Dim dbErrors As Database
    Dim strDbName As String
    Dim rsTest As Recordset
    Dim strTmp As String

    On Error GoTo LoadError

  ' Get the database name and open the database.
    strDbName = strNWindDb()       ' NWindPath is a function in READINI.BAS
10  Set dbErrors = DBEngine.Workspaces(0).OpenDatabase(strDbName)
    
    ' This statement will cause an error, because there's no such table
    ' as No Such Table.
20  Set rsTest = dbErrors.OpenRecordset("No Such Table", dbOpenTable)

    ' There is a table named Products, so this one should work.
30  Set rsTest = dbErrors.OpenRecordset("Products", dbOpenTable)

    ' There's no such field as No Such Field, so here's another error.
40  strTmp = rsTest![No Such Field]

    ' This causes an error because UnitPrice only takes currency values.
50  rsTest![UnitPrice] = "XYZ"

    ' Finally!
60  End

Exit Sub

LoadError:
    MsgBox "Error #" & Str$(Err.Number) & " at Line " & Str$(Erl) & " - " & Err.Description & " - reported by " & Err.Source
Resume Next

End Sub

⌨️ 快捷键说明

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