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

📄 createdb.frm

📁 vb写的试题库生成系统
💻 FRM
字号:
VERSION 5.00
Begin VB.Form CreateDB 
   BorderStyle     =   3  'Fixed Dialog
   Caption         =   "创建试题数据库"
   ClientHeight    =   1605
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   4725
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   1605
   ScaleWidth      =   4725
   ShowInTaskbar   =   0   'False
   StartUpPosition =   2  '屏幕中心
   Begin VB.CommandButton cmdExit 
      Cancel          =   -1  'True
      Caption         =   "关闭"
      Height          =   315
      Left            =   2400
      TabIndex        =   3
      Top             =   945
      Width           =   1305
   End
   Begin VB.TextBox txtName 
      Height          =   300
      Left            =   1297
      TabIndex        =   1
      Top             =   416
      Width           =   3060
   End
   Begin VB.CommandButton cmdCreate 
      Caption         =   "创建数据库"
      Default         =   -1  'True
      Height          =   315
      Left            =   1027
      TabIndex        =   0
      Top             =   945
      Width           =   1305
   End
   Begin VB.Label Label1 
      AutoSize        =   -1  'True
      Caption         =   "数据库名称"
      Height          =   180
      Left            =   367
      TabIndex        =   2
      Top             =   476
      Width           =   900
   End
End
Attribute VB_Name = "CreateDB"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub cmdCreate_Click()

Dim conn As New ADODB.Connection
Dim rst As New ADODB.Recordset
Dim cmd As New ADODB.Command

With conn
.ConnectionString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False"
.Open
strSQL = " Create Database " & Trim(txtName)

.Execute strSQL
        '建立数据库连接
        
        conn.Close
    conn.ConnectionString = _
    "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=" & Trim(txtName)
    conn.Open
    
    '创建“判断题”数据表
        
        strSQL = "Create Table 判断题 (" _
                & "编号 int identity primary key," _
                & "章节 int  not null," _
                & "题干 varchar(200)  not null," _
                & "图片 varchar(50)," _
                & "难度 tinyint not null," _
                & "答案 bit not null)"
        conn.Execute strSQL

        '创建“单选题”数据表
        strSQL = "Create Table 单选题 (" _
                & "编号 int identity primary key," _
                & "章节 int  not null," _
                & "题干 varchar(200) not null," _
                & "图片 varchar(100)," _
                & "选项1 varchar(100) not null," _
                & "选项2 varchar(100) not null," _
                & "选项3 varchar(100) not null," _
                & "选项4 varchar(100) not null," _
                & "难度 tinyint not null," _
                & "答案 tinyint not null)"
       conn.Execute strSQL

        '创建“多选题”数据表,答案以“1001”形式保存,1表示选,0表示不选。
        strSQL = "Create Table 多选题 (" _
                & "编号 int identity primary key," _
                & "章节 int  not null," _
                & "题干 varchar(200) not null," _
                & "图片 varchar(100)," _
                & "选项1 varchar(100) not null," _
                & "选项2 varchar(100) not null," _
                & "选项3 varchar(100) not null," _
                & "选项4 varchar(100) not null," _
                & "难度 tinyint not null," _
                & "答案 varchar(4) not null)"
        conn.Execute strSQL

        '创建“填空题”数据表,每题只能一个空
        strSQL = "Create Table 填空题 (" _
                & "编号 int identity primary key," _
                & "章节 int  not null," _
                & "图片 varchar(50)," _
                & "题干 varchar(200) not null," _
                & "难度 tinyint not null," _
                & "答案1 varchar(50) not null," _
                & "答案2 varchar(50))"
       conn.Execute strSQL
       
        '创建“简答题”数据表,每题只能一个空
        strSQL = "Create Table 简答题 (" _
                & "编号 int identity primary key," _
                & "章节 int  not null," _
                & "图片 varchar(50)," _
                & "题干 varchar(200) not null," _
                & "难度 tinyint not null," _
                & "答案 varchar(500) not null)"
        conn.Execute strSQL
        '创建“章节”数据表
        strSQL = "Create Table 章节 (" _
                & "编号 int identity primary key," _
                & "名称 varchar(50)  not null)"
        conn.Execute strSQL
        
        
        End With
        Set conn = Nothing
        MsgBox "数据库已成功创建!"
'        conn.Close
End Sub
'showError "程序执行出错,错误信息如下:" & vbCrLf & Err.Description
Private Sub cmdExit_Click()
    Unload Me               '关闭窗体
End Sub

⌨️ 快捷键说明

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