Imports System
Imports System.data.OleDb
Module DBConn
Public con As OleDbConnection
Public cmd As OleDbCommand
Public Reader as OleDbDataReader
Public Sub DBConn(filename as String)
Dim strDBCon as String
strDBCon = “Provider=Microsoft.jet.OLEDB.4.0;Data source=%filename%;Persist Security Info=False”
strDBCon.Replace(“%filename%”, filename)
Set con = New OleDbConnection(strDBCon)
con.Open()
End Sub
Public Sub DBFree()
con.Close()
Set con = Nothing
End Sub
‘SELECT
Public Sub SELECT(qry as String)
Dim strQry as String
strQry = qry
Set cmd = New OleDbCommand(strQry, con)
Reader = cmd.ExecuteReader(CommandBehavior.CloseConnection)
While Reader.Read
Console.WriteLine(Reader(“필드명”))
End While
Set cmd = Nothing
End Sub
‘INSERT, UPDATE
Public Sub INSERT(qry as String)
Dim strQry as String
strQry = qry
Set cmd = New OleDbCommand(strQry, con)
ret = cmd.ExecuteNonQry(strQry)
if ret = true
else
end if
Set cmd = Nothing
End Sub
End Module