0% found this document useful (0 votes)
31 views

Query Execution

This document defines several shared functions and subroutines for querying a database and managing user authentication in VB.NET. It includes functions for opening a recordset from a query string, filling a data table, executing queries, hashing passwords, and getting/setting the current user name, ID, and access level.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views

Query Execution

This document defines several shared functions and subroutines for querying a database and managing user authentication in VB.NET. It includes functions for opening a recordset from a query string, filling a data table, executing queries, hashing passwords, and getting/setting the current user name, ID, and access level.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 2

Shared Function db_dt(ByVal query As String) Try rs = New ADODB.Recordset rs.CursorLocation = CursorLocationEnum.adUseClient rs.CursorType = CursorTypeEnum.adOpenDynamic rs.LockType = LockTypeEnum.adLockOptimistic rs.

Open(query, conn) da = New OleDb.OleDbDataAdapter dt = New DataTable da.Fill(dt, rs) Catch ex As Exception MsgBox(ex.Message, MsgBoxStyle.Critical, "Query Error") dt = Nothing End Try Return dt End Function Shared Sub queries(ByVal query As String, ByVal msg As String) Try conn.Execute(query) If (msg <> "") Then MsgBox(msg, MsgBoxStyle.Information, "Save") End If Catch ex As Exception MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Error") End Try End Sub Shared Sub resetval() dt = Nothing End Sub Shared Function en_pword(ByVal pword As String) Dim oEncoder As New System.Text.ASCIIEncoding() Dim pass As Byte() = oEncoder.GetBytes(pword) Dim obj_md5 As New System.Security.Cryptography.MD5CryptoServiceProvider Dim strPassword As String = BitConverter.ToString(obj_md5.ComputeHash(pass)) Return strPassword End Function Shared Function db_rs(ByVal query As String) Try rs = New ADODB.Recordset rs.CursorLocation = CursorLocationEnum.adUseClient rs.CursorType = CursorTypeEnum.adOpenDynamic rs.LockType = LockTypeEnum.adLockOptimistic rs.Open(query, conn) Catch ex As Exception MsgBox(ex.Message, MsgBoxStyle.Critical, "Query Error") End Try Return rs End Function Shared Sub set_UserName(ByVal username As String) uname = username End Sub Shared Function get_UserName() Return uname

End Function Shared Sub set_UserID(ByVal uid As String) userid = uid End Sub Shared Function get_userID() Return userid End Function Shared Sub set_UserLevel(ByVal userlevel As String) ulevel = userlevel End Sub Shared Function get_userLevel() Return ulevel End Function End Class

You might also like