毕业论文论文范文课程设计实践报告法律论文英语论文教学论文医学论文农学论文艺术论文行政论文管理论文计算机安全
您现在的位置: 毕业论文 >> 课程设计 >> 正文

VB图书管理系统源代码 第4页

更新时间:2009-7-10:  来源:毕业论文
VB图书管理系统源代码 第4页
Dim SqlString As String
    Dim OrderString As String
    Dim QueryString As String
    '这三个字符串变量用来存储查询语句
    'SqlString变量用来存储查询语句中除了ORDER BY子句之外的部分
    'OrderString变量用来存储ORDER BY子句
    'QueryString变量存储查询语句
    Private Sub 综合查询_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        '初始化列表“cmbBox查询表”
        Me.cmbBox查询表.Items.Add("读者信息")
        Me.cmbBox查询表.Items.Add("管理者信息")
        Me.cmbBox查询表.Items.Add("借阅信息")
        Me.cmbBox查询表.Items.Add("书籍信息")
        Me.cmbBox查询表.Items.Add("出版社信息")
        Me.cmbBox查询表.SelectedIndex = 0       '将列表的第一项设为选中项
    End Sub
    Private Sub cmbBox查询表_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbBox查询表.SelectedIndexChanged
        '在“cmbBox查询表”中选择一项作为查询表
        '则在“cmbBox查询依据”“cmbBox排序依据”将自动填充
        '查询表中的所有字段
        '保持数据表与字段二者的一致性
        Dim str_Table As String
        str_Table = Me.cmbBox查询表.SelectedItem
        If str_Table = "" Then Return
        Me.cmbBox查询依据.Items.Clear()
        Me.cmbBox排序依据.Items.Clear()
        Dim mySelectQuery As String = "SELECT * FROM " + str_Table
        Dim myCommand As New OleDb.OleDbCommand(mySelectQuery, Me.OleDbConnection1)
        If Me.OleDbConnection1.State = ConnectionState.Closed Then
            Me.OleDbConnection1.Open()
        End If
        Dim myReader As OleDb.OleDbDataReader
        myReader = myCommand.ExecuteReader
        Dim i As Integer
        For i = 0 To myReader.FieldCount - 1
            DataType(i) = myReader.GetFieldType(i).Name
            Me.cmbBox排序依据.Items.Add(myReader.GetName(i).ToString)
            Me.cmbBox查询依据.Items.Add(myReader.GetName(i).ToString)
        Next
        myReader.Close()
        Me.cmbBox查询依据.SelectedIndex = 0
        Me.cmbBox排序依据.SelectedIndex = 0
    End Sub
    Private Sub btn执行查询_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn执行查询.Click
        If DataType(Me.cmbBox查询依据.SelectedIndex) = "Int32" Then
            SqlString = "SELECT * FROM " + Me.cmbBox查询表.Text + " WHERE"
            SqlString = SqlString + Me.cmbBox查询依据.Text + " " + _
            Me.cmbBox运算符.Text + " " + "(" + Me.edit指定值.Text + ")"
        ElseIf DataType(Me.cmbBox查询依据.SelectedIndex) = "String" Then
            SqlString = "SELECT * FROM " + Me.cmbBox查询表.Text + " WHERE"
            SqlString = SqlString + Me.cmbBox查询依据.Text + " " + _
            Me.cmbBox运算符.Text + " " + "'" + Me.edit指定值.Text + "'"
        ElseIf DataType(Me.cmbBox查询依据.SelectedIndex) = "Date" Then
            SqlString = "SELECT * FROM " + Me.cmbBox查询表.Text + " WHERE"
            SqlString = SqlString + Me.cmbBox查询依据.Text + " " + _
            Me.cmbBox运算符.Text + "Cdate(" + Me.edit指定值.Text + ")"
        End If
        OrderString = Me.cmbBox排序依据.Text
        QueryData(SqlString, OrderString)
        If Me.cmbBox查询表.Text = "读者信息" Then
            Me.OleDbInsertCommand2.CommandText = QueryString
        End If
        If Me.cmbBox查询表.Text = "管理者信息" Then
            Me.OleDbInsertCommand3.CommandText = QueryString
        End If
        If Me.cmbBox查询表.Text = "借阅信息" Then
            Me.OleDbInsertCommand4.CommandText = QueryString
        End If
        If Me.cmbBox查询表.Text = "书籍信息" Then
            Me.OleDbInsertCommand5.CommandText = QueryString
        End If
        If Me.cmbBox查询表.Text = "出版社信息" Then
            Me.OleDbInsertCommand1.CommandText = QueryString
        End If
        Try
            Me.LoadDataSet()    '尝试加载数据集
            Me.DataGrid1.DataMember = Me.cmbBox查询表.Text
        Catch eLoad As System.Exception
            System.Windows.Forms.MessageBox.Show(eLoad.Message)
        End Try
    End Sub

上一页  [1] [2] [3] [4] [5] [6] [7] [8] 下一页

VB图书管理系统源代码 第4页下载如图片无法显示或论文不完整,请联系qq752018766
设为首页 | 联系站长 | 友情链接 | 网站地图 |

copyright©751com.cn 辣文论文网 严禁转载
如果本毕业论文网损害了您的利益或者侵犯了您的权利,请及时联系,我们一定会及时改正。