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=Microsoft.Jet.OLEDB.4.0; Data Source="");
OleDbCommand command = conn.CreateCommand();
string strSQL = "SELECT * FROM Employee";
ds = new DataSet();
conn.Open();
command.CommandText = strSQL;
OleDbDataAdapter adapter = new OleDbDataAdapter(command);
adapter.Fill(ds);
dataGridView1.DataSource = ds.Tables[0];
dataGridView1.ReadOnly = true;
conn.Close();
where should i change to decrypt those data before showing it in the datagrid?
14 6770
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)read["Username"];
encryption.decrypt(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
}
Well, populate your DataSet, then loop through the dataset.
Well, populate your DataSet, then loop through the dataset.
can you example please..:)
-
//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.datatable because it does not contain public definition for getenumerator...
it says that foreach statement cannot operate on variables of type system.data.datatable 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=datagridview1.columns["EmployeeUsername"];
then how do i change objects to strings and putting it back to the grid?
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
-
}
-
-
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
-
}
-
foreach(datarow r in retval.tables[0]) cannot be executed
i've head of cell formatting but how does it applies..
foreach(datarow r in retval.tables[0]) cannot be executed
i've head of cell formatting but how does it applies..
Did you switch it to:
foreach(datarow r in retval.tables[0].Rows)
???
Did you switch it to:
foreach(datarow r in retval.tables[0].Rows)
???
yes i did....
foreach(datarow r in retval.tables[0].Rows)
{
object o = r["EmployeeUserName"];
string a = (string) o;
string b = Encryption.Decrypt(a, true);
}
i used a messageBox.show(); to see the result it did change the values
next is to put the decrypted values inside the datagridview..any ideal how?
next is to put the decrypted values inside the datagridview..any ideal how?
Just assign them back again? -
foreach(datarow r in retval.tables[0].Rows)
-
{
-
object o = r["EmployeeUserName"];
-
string a = (string) o;
-
string b = Encryption.Decrypt(a, true);
-
//like this maybe?
-
r["EmployeeUserName"].value=b;
-
}
-
foreach(datarow r in retval.tables[0].Rows)
{
object o = r["EmployeeUserName"];
string a = (string) o;
string b = Encryption.Decrypt(a, true);
}
i got it!!!!
just add the r["employeename"] = 'decrypted value'; inside the foreeach loop
thanks man!!!!!!!!!
thank you for ur precious time!!!!!!!!!
thank you so much Plater!!!! really appriciate your help!!!!!!!
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| |