Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
' --- Return a set of Records ---
Dim ds As DataSet
Dim dt As DataTable
ds = DataClass.GetDataSet(<SQL Query String>)
dt = ds.Tables(0)
If dt.Rows.Count >= 1 Then
< do something with the record(s) >
Else
' --- No Records Returned ---
Endif
Imports MySql.Data.MySqlClient
Public Module CLETSConnect
Dim StatColor As Color
Dim ConnStr As String
Public Sub ConnCLET()
Dim cletconn As MySqlConnection
cletconn = New MySqlConnection()
cletconn.ConnectionString = "server=localhost;user id=root;password=rootpw;database=" & Mnemonic
Try
cletconn.Open()
StatColor = Color.Green
ConnStr = "CLETS Connected"
cletconn.Close()
Catch errors As MySqlException
StatColor = Color.Red
ConnStr = "CLETS NOT CONNECTED"
End Try
End Sub
End Module
Public Class DataClass
Public Shared Function GetDataReader(ByVal sql As String) As Data.OleDb.OleDbDataReader
Dim cDataPath As String = ""
Dim Conn As New System.Data.OleDb.OleDbConnection
Dim Cmd As New System.Data.OleDb.OleDbCommand
Dim reader As System.Data.OleDb.OleDbDataReader = Nothing
GetDataReader = Nothing
Try
cDataPath = [u]< UNC and/or fully pathed String defining where to find data >[/u]
' --- Use cDataPath in the following Connection String ---
Conn.ConnectionString = [u]< Your specific MySQL Connection String >[/u]
Cmd.Connection = Conn
Cmd.CommandText = sql ' --- Passed as Parameter to this Class's Function --
Cmd.Connection.Open()
GetDataReader = Cmd.ExecuteReader
Catch ex As Exception
' --- Close/Clear Open Objects ---
GetDataReader = Nothing
Conn.Close()
Conn.Dispose()
HttpContext.Current.Session("sql") = Nothing
' --- Write out Error to Log File ---
' --- Examine [u]ex.Message[/u] to understand error specifics ---
LogError("GetDataReader:" & ex.Message & vbCrLf & ex.Source & ex.StackTrace & vbCrLf & " DataPath: " & cDataPath & vbCrLf & " SQL:" & sql)
End Try
HttpContext.Current.Session("sql") = Nothing
End Function
End Class
GetDataSet(<SQL Query String>)
but have you confirmed that it is truly being 'seen' by this Function so as to result in an accurate MySQL Connection String?the variable 'Mnemonic' in this case is defined by a form prior to referencing this module