數據庫人員面試:SQL Server常用測試題(1
·PHP連接數據庫的方法(3)
·InterBase 數據庫函數庫
·圖解MySQL數據庫的安裝和操作 (1)
·PHP中使用類對數據庫進行操作
·[冷楓推薦]:數據庫操作,內外聯查詢,分
·用JSP從數據庫中讀取圖片並顯示在網頁上
·ACESS數據庫與WEB頁連接
·DB2 9數據庫免費版下載地址
·利用外部命令Oralce數據庫導入導出
程序圖例
-------------------------------------
軟件說明:包含源碼
說明: frmMain表單一個
Private Sub Command1_Click()
On Error GoTo Err100
'定義表與字段
Dim DefDatabase As Database
Dim DefTable As TableDef, DefField As FIEld
Set DefDatabase = Workspaces(0).OpenDatabase(App.Path & "\VB-CODE.MDB", 0, False)
Set DefTable = DefDatabase.CreateTableDef("中國")
'dbBinary = 9
'dbBoolean = 1
'dbByte = 2
'dbChar=18
'dbDate=8
'dbInteger=3
'dbLong=4
'dbMemo=12
'dbText=10
'建立Name字段為8個字符型
Set DefField = DefTable.CreateFIEld("Name", dbText, 8)
DefTable.Fields.Append DefFIEld
Set DefField = DefTable.CreateFIEld("Sex", dbText, 2)
DefTable.Fields.Append DefFIEld
'該字段允許為空
DefFIEld.AllowZeroLength = True
'建立Age字段為3個的常整型
Set DefField = DefTable.CreateFIEld("Age", dbInteger, 3)
'字段追加
DefTable.Fields.Append DefFIEld
'表追加
DefDatabase.TableDefs.Append DefTable
MsgBox " 一切 OK , 《中國》表已經建立完成! ", vbInformation
Exit Sub
Err100:
MsgBox "對不起,不能建立表。請先再建表前建立VB-CODE數據庫? ", vbCritical
End Sub
Private Sub cmdCreate_Click()
On Error GoTo Err100
'建立名為 VB-CODE 的數據庫
CreateDatabase "VB-CODE", dbLangGeneral
MsgBox " 一切 OK , 數據庫建立完成! ", vbInformation
Exit Sub
Err100:
MsgBox "不能建立數據庫! " & vbCrLf & vbCrLf & Err.Description, vbInformation
End Sub