'Find by ClinicID button Public Function findById(cId As String) As List(Of Hashtable) 'Instantiates a connection object Dim oConnection As OleDbConnection = New OleDbConnection(CONNECTION_STRING) 'Instantiates a list of hashtables Dim lsData As New List(Of Hashtable) Try Debug.Print("Connection string: " & oConnection.ConnectionString) oConnection.Open() Dim oCommand As OleDbCommand = New OleDbCommand oCommand.Connection = oConnection 'Stored in the CommandText property of the command object oCommand.CommandText = "SELECT * FROM clinics WHERE clinic_id = ?;" oCommand.Parameters.Add("ClinicID", OleDbType.Integer, 8) oCommand.Parameters("ClinicID").Value = CInt(cId) 'Compiles the prepared statement oCommand.Prepare() 'Executes the SQL statement and stores the results in data reader object Dim oDataReader = oCommand.ExecuteReader() 'Process data set in Hashtable Dim htTempData As Hashtable Do While oDataReader.Read() = True htTempData = New Hashtable htTempData("ClinicID") = CStr(oDataReader("clinic_id")) htTempData("ClinicName") = CStr(oDataReader("clinic_name")) htTempData("ClinicAddress") = CStr(oDataReader("address")) htTempData("ClinicFirstName") = CStr(oDataReader("contact_firstname")) htTempData("ClinicLastName") = CStr(oDataReader("contact_lastname")) htTempData("ClinicEmail") = CStr(oDataReader("email")) htTempData("ClinicPhone") = CStr(oDataReader("phone")) lsData.Add(htTempData) Loop Debug.Print("The record was found.") Catch ex As Exception Debug.Print("ERROR:" & ex.Message) MsgBox("An error occured!") Finally oConnection.Close() End Try 'Return list of hashtables to the calling function Return lsData End Function
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)