internal byte[] getTemplateFromKey(int primaryKey) { OleDbConnection myDbConnection = new OleDbConnection(connectionString); byte[] decryptedTemplate = null; try { string queryString; byte[] encryptedTemplate = null; cryptography decrypt = new cryptography(); queryString = String.Format("SELECT template from myTable where PrimaryKey = {0}", primaryKey); OleDbCommand command = new OleDbCommand(queryString, myDbConnection); myDbConnection.Open(); OleDbDataReader reader = command.ExecuteReader(); while (reader.Read()) { encryptedTemplate = (byte[])reader.GetValue(0); decryptedTemplate = decrypt.decryptBytes(encryptedTemplate); } reader.Close(); return(decryptedTemplate); } catch (OleDbException ex) { DisplayOleDbErrorCollection(ex); return(decryptedTemplate); } finally { myDbConnection.Close(); } }
internal Bitmap getImageFromId(string userId) { Bitmap dbaseImage = null; OleDbConnection myDbConnection = new OleDbConnection(connectionString); try { string queryString; byte[] encryptedImageArray = null; byte[] decryptedImageArray = null; cryptography decrypt = new cryptography(); queryString = String.Format("SELECT picture from myTable where userId = '{0}'", decrypt.encryptString(userId)); OleDbCommand command = new OleDbCommand(queryString, myDbConnection); myDbConnection.Open(); OleDbDataReader reader = command.ExecuteReader(); while (reader.Read()) { encryptedImageArray = (byte[])reader.GetValue(0); decryptedImageArray = decrypt.decryptBytes(encryptedImageArray); MemoryStream stream = new MemoryStream(decryptedImageArray); dbaseImage = (Bitmap)Image.FromStream(stream); } reader.Close(); return(dbaseImage); } catch (OleDbException ex) { DisplayOleDbErrorCollection(ex); return(dbaseImage); } finally { myDbConnection.Close(); } }
internal byte[] getTemplateFromId(string userId) { cryptography deCrypt = new cryptography(); OleDbConnection myDbConnection = new OleDbConnection(connectionString); byte[] encryptedTemplateArray = null; byte[] templateArray = null; string queryString = String.Format("SELECT template from myTable where userId = '{0}'", deCrypt.encryptString(userId)); OleDbCommand command = new OleDbCommand(queryString, myDbConnection); try { myDbConnection.Open(); OleDbDataReader reader = command.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { encryptedTemplateArray = (byte[])reader.GetValue(0); templateArray = deCrypt.decryptBytes(encryptedTemplateArray); } } reader.Close(); return(templateArray); } catch (OleDbException ex) { DisplayOleDbErrorCollection(ex); return(templateArray); } finally { myDbConnection.Close(); } }