公共模塊

Imports System.Data
Imports System.Data.OleDb


Module 公共模塊
    Public bo As String  '模塊級別的變量記錄用戶名


    Public adocmd As OleDbDataAdapter
    Public ds As DataSet
    Public mytable As Data.DataTable


    Public com_fdir As New System.IO.DirectoryInfo(Application.StartupPath)
    Public com_fdist As String = com_fdir.Parent.Parent.Parent.Parent.Parent.FullName.ToString


    '自定義函數過程,用於查詢數據
    Public Function executesql(ByVal sql As String, ByVal table As String)
        'Console.WriteLine("com_fdir = " & com_fdir.ToString)
        'Console.WriteLine("com_fdist = " & com_fdist)
        Dim database_dir As String = com_fdist & "\bookmanage\bookmanage1.mdb "
        adocmd = New OleDbDataAdapter(sql, "provider = microsoft.jet.oledb.4.0;data source = " & database_dir & ";Jet OLEDB:DataBase password = Dhb321;")
        ds = New DataSet
        adocmd.Fill(ds, table)
        mytable = ds.Tables.Item(0)
    End Function


    '自定義函數過程,用於查詢數據,異常拋出
    Public Function executesql(ByVal sql As String, ByVal table As String, ByRef x_p As String)
        Dim database_dir As String = com_fdist & "\bookmanage\bookmanage1.mdb "
        adocmd = New OleDbDataAdapter(sql, "provider = microsoft.jet.oledb.4.0;data source =" & database_dir & ";Jet OLEDB:DataBase password = Dhb321;")
        ds = New DataSet
        adocmd.Fill(ds, table)
        mytable = ds.Tables.Item(0)


        Console.WriteLine("executesql = " + mytable.Rows(0)(0))


        'Dim newrow As DataRow
        'newrow = mytable.NewRow
        'MsgBox(mytable.Rows.Item(1).Item(0))
        'Console.WriteLine(newrow.Item(0))
        'MsgBox(newrow.Item(0))
        'MsgBox(x_p)


        'If newrow.Item(0) <> x_p Then


        'End If


    End Function


End Module
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章