hi guys..im new to datagridview and im wondering is there a way to convert an encrypted data in access and show it in a datagridview? im using C# and microsoft access
normally this is how to show data in datagridview:
OleDbConnection conn = new OleDbConnection ("Provider=Micr osoft.Jet.OLEDB .4.0;Data Source="");
OleDbCommand command = conn.CreateComm and();
string strSQL = "SELECT * FROM Employee";
ds = new DataSet();
conn.Open();
command.Command Text = strSQL;
OleDbDataAdapte r adapter = new OleDbDataAdapte r(command);
adapter.Fill(ds );
dataGridView1.D ataSource = ds.Tables[0];
dataGridView1.R eadOnly = true;
conn.Close();
where should i change to decrypt those data before showing it in the datagrid?
14 6840 Plater 7,872
Recognized Expert Expert
Do you know how to un-encrypt it? If so, just run the decrypting on the data kep in the dataset?
Do you know how to un-encrypt it? If so, just run the decrypting on the data kep in the dataset?
yes..i know how to decrypt it. but what im doing is to decrypt it 1 at a time
eg. temp=(string)re ad["Username"];
encryption.decr ypt(temp, true);
this decrypts the username only..the problem is i dont know how to show this in the datagrid. all this while i used this method only in a while loop.
eg.
while(read.read ())
{
//decrypt
}
Plater 7,872
Recognized Expert Expert
Well, populate your DataSet, then loop through the dataset.
Well, populate your DataSet, then loop through the dataset.
can you example please..:)
Plater 7,872
Recognized Expert Expert -
//myq is a string with my SELECT sql statement
-
//dbcon is my database connection
-
//you will probably not use the Sql namespace but like odb namespace
-
DataSet retval= new DataSet();
-
SqlDataAdapter dba = new SqlDataAdapter(myq, dbcon);
-
dba.Fill(retval);
-
//now your dataset is populated with values
-
//retval.Tables[0] will give you your DataTable
-
-
//then you can loop through
-
foreach(DataRow r in retval.Tables[0].Rows)
-
{
-
//decrypt the data in each column of the row and save it back to the row
-
}
-
Maybe someone knows a better way, but this is what came to my mind.
-
//myq is a string with my SELECT sql statement
-
//dbcon is my database connection
-
//you will probably not use the Sql namespace but like odb namespace
-
DataSet retval= new DataSet();
-
SqlDataAdapter dba = new SqlDataAdapter(myq, dbcon);
-
dba.Fill(retval);
-
//now your dataset is populated with values
-
//retval.Tables[0] will give you your DataTable
-
-
//then you can loop through
-
foreach(DataRow r in retval.Tables[0])
-
{
-
//decrypt the data in each column of the row and save it back to the row
-
}
-
Maybe someone knows a better way, but this is what came to my mind.
it says that foreach statement cannot operate on variables of type system.data.dat atable because it does not contain public definition for getenumerator.. .
Plater 7,872
Recognized Expert Expert
it says that foreach statement cannot operate on variables of type system.data.dat atable because it does not contain public definition for getenumerator.. .
Oops!
(I fixed it in the above code as well)
Use: -
foreach(DataRow r in retval.Tables[0].Rows)
-
-
foreach(DataRow r in retval.Tables[0].Rows)
-
this works fine:) but i cant seem to get values out of the datagrid
is this even correct?
object value=datagridv iew1.columns["EmployeeUserna me"];
then how do i change objects to strings and putting it back to the grid?
Plater 7,872
Recognized Expert Expert
Try this: -
//then you can loop through
-
foreach(DataRow r in retval.Tables[0])
-
{
-
//decrypt the data in each column of the row and save it back to the row
-
object o = r["mycolumnname"].Value;
-
//r["mycolumnname"] should also have a like .ColumnType property or something to tell you what the object really is
-
//If need be you can use o.GetType() to determine the valuetype too
-
}
-
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: sffan |
last post by:
I am new to database programming and was curious how others solve the
problem of storing encrypted in data in db table columns and then
subsequently searching for these records.
The particular problem that I am facing is in dealing with (privacy)
critical information like credit-card #s and SSNs or business critical
information like sales opportunity size or revenue in the database. The
requirement is that this data be stored encrypted...
|
by: Nico |
last post by:
My database have 20 tables and many users. I wish to store encrypted
data in 3 tables and have only 3 users have access to them, walking
into tables or using forms.
Can someone point me a direct help or something to read?
Tnx
Nico
|
by: Burke Atilla |
last post by:
While encrypting data with DES through CryptoStream makes encrypted data bigger than original string. if we have 8 byte key and 8 byte of data then the mode is ECB. output encrypted data is 16 bytes long. first 8 bytes is out encrypted key but last 8 byte unknown. and while decrypting if we couldn't supply this 8 bytes we couldnt decrypt data. and get exception "Bad Data"
What is this 8 bytes
and how can i supply this data if i have only the...
|
by: Leonardo D'Ippolito |
last post by:
Hi!
I have two .NET win apps that need to communicate on a TCP/IP network.
'App A' must ask 'app B' if it's allowed to do some task, and 'app B'
must authorize or prohibit it.
How can I do this kind of communication in a secure way (protected
from sniffing)? It would be a very simple protocol. Question, and two
possible answers 'yes' or 'no'.
|
by: robert |
last post by:
Hello,
I want to put (incrementally) changed/new files from a big file tree
"directly,compressed and password-only-encrypted" to a remote backup
server incrementally via FTP,SFTP or DAV.... At best within a closed
algorithm inside Python without extra shell tools.
(The method should work with any protocol which allows somehow read,
write & seek to a remote file.)
On the server and the transmission line there should never be...
| |
by: Michael Sperlle |
last post by:
Is it possible? Bestcrypt can supposedly be set up on linux, but it seems
to need changes to the kernel before it can be installed, and I have no
intention of going through whatever hell that would cause.
If I could create a large file that could be encrypted, and maybe add
files to it by appending them and putting in some kind of delimiter
between files, maybe a homemade version of truecrypt could be constructed.
Any idea what it...
|
by: Ivan |
last post by:
I have a class Foo which have two property. I have a thread that do
some process and update class Foo int B. I have a datagridview on main
form. this datagridview data source to this class Foo and column A
binds to string A and column B binds to int B. When i start two
threads, the datagridview able to show two rows and updated int B at
run time. How?
public class Foo
{
public Foo()
|
by: Rick Shaw |
last post by:
Hi, I have a problem with the datagridview not refreshed when the
application first appear on the screen.
The datagridview display data from a table in the dataset. At the same
time, I've added checkbox columns that are not bounded the table.
This datagridview is located in the tab (2nd). I thought I mention that
since that might be part of the problem (?).
When the applications start, it will need some parameter criteria selection...
|
by: Bernard Dhooghe |
last post by:
The information center writes:
"Encryption Algorithm: The internal encryption algorithm used is RC2
block cipher with padding, the 128-bit secret key is derived from the
password using a MD2 message digest.
"
and also explains how the length of the encrypted column can be
derived.
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |