Imports System.Data.SqlClient
Module SQL_Module
    Public ConString As String : Public SQL1, SQL2, SQL3, SQL4, SQL5 As String
    Public conn As New SqlConnection : Public cmd As New SqlCommand : Public dr As SqlDataReader : Public da As New SqlDataAdapter
    Public DTP As String : Public DTP1 As String : Public DTP2 As String : Public DTP3 As String : Public DTP4 As String
    Public 登入權限 As String = "姓名, 帳號, 密碼, 職稱, 級別, CC01, CC02, CC03, CC04, CC05, CC06, CC07, CC08, CC09, CC10, CC11, CC12, CC13, CC14, CC15, CC16, CC17, CC18, CC19, CC20, CC21,
                                 CC22, CC23, CC24, CC25, CC26, CC27, CC28, CC29, CC30, CC31, CC32, CC33, CC34, CC35, CC36, CC37, CC38, CC39, CC40, CC41, CC42, CC43, CC44, CC45, CC46, CC47, 
                                 CC48, CC49, CC50, CC51, CC52, CC53, CC54, CC55, CC56 "
    Public 權限數量 As Integer = 56
    Friend Sub ConnOpen()
        conn.Close() : If conn.State = ConnectionState.Closed Then : conn.ConnectionString = ConString : conn.Open() : End If
    End Sub
    Friend Sub CmdSet_For_DGV()
        cmd.Connection = conn : cmd.CommandText = SQL1 : da.SelectCommand = cmd
    End Sub
    Friend Sub CmdSet_For_dr()
        cmd.CommandText = SQL1 : cmd.Connection = conn : dr = cmd.ExecuteReader
    End Sub
    Friend Sub CmdSet_For_dr_pic()
        Dim fs As FileStream : fs = File.OpenRead(PA49) : Dim picb(fs.Length) As Byte : fs.Read(picb, 0, fs.Length) : fs.Close() : cmd.Parameters.Clear()
        cmd.CommandText = SQL1 : cmd.Parameters.Add("@binary_file", SqlDbType.VarBinary).Value = picb : cmd.Connection = conn : dr = cmd.ExecuteReader
    End Sub
End Module
