473,811 Members | 3,610 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Encrypted data in datagridview

47 New Member
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?
Oct 8 '07 #1
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?
Oct 8 '07 #2
wassssup
47 New Member
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
}
Oct 8 '07 #3
Plater
7,872 Recognized Expert Expert
Well, populate your DataSet, then loop through the dataset.
Oct 8 '07 #4
wassssup
47 New Member
Well, populate your DataSet, then loop through the dataset.
can you example please..:)
Oct 8 '07 #5
Plater
7,872 Recognized Expert Expert
Expand|Select|Wrap|Line Numbers
  1. //myq is a string with my SELECT sql statement
  2. //dbcon is my database connection
  3. //you will probably not use the Sql namespace but like odb namespace
  4. DataSet retval= new DataSet();
  5. SqlDataAdapter dba = new SqlDataAdapter(myq, dbcon);
  6. dba.Fill(retval);
  7. //now your dataset is populated with values
  8. //retval.Tables[0] will give you your DataTable
  9.  
  10. //then you can loop through
  11. foreach(DataRow r in retval.Tables[0].Rows)
  12. {
  13.    //decrypt the data in each column of the row and save it back to the row
  14. }
  15.  

Maybe someone knows a better way, but this is what came to my mind.
Oct 8 '07 #6
wassssup
47 New Member
Expand|Select|Wrap|Line Numbers
  1. //myq is a string with my SELECT sql statement
  2. //dbcon is my database connection
  3. //you will probably not use the Sql namespace but like odb namespace
  4. DataSet retval= new DataSet();
  5. SqlDataAdapter dba = new SqlDataAdapter(myq, dbcon);
  6. dba.Fill(retval);
  7. //now your dataset is populated with values
  8. //retval.Tables[0] will give you your DataTable
  9.  
  10. //then you can loop through
  11. foreach(DataRow r in retval.Tables[0])
  12. {
  13.    //decrypt the data in each column of the row and save it back to the row
  14. }
  15.  

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.. .
Oct 8 '07 #7
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:
Expand|Select|Wrap|Line Numbers
  1. foreach(DataRow r in retval.Tables[0].Rows)
  2.  
Oct 8 '07 #8
wassssup
47 New Member
Expand|Select|Wrap|Line Numbers
  1. foreach(DataRow r in retval.Tables[0].Rows)
  2.  
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?
Oct 8 '07 #9
Plater
7,872 Recognized Expert Expert
Try this:
Expand|Select|Wrap|Line Numbers
  1. //then you can loop through
  2. foreach(DataRow r in retval.Tables[0])
  3. {
  4.    //decrypt the data in each column of the row and save it back to the row
  5.    object o = r["mycolumnname"].Value;
  6.    //r["mycolumnname"] should also have a like .ColumnType property or something to tell you what the object really is
  7.    //If need be you can use o.GetType() to determine the valuetype too
  8. }
  9.  
Oct 8 '07 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

10
5495
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...
5
2266
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
4
4586
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...
2
5144
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'.
8
2783
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...
5
6782
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...
2
5025
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()
2
8740
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...
2
7697
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.
0
9724
marktang
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...
0
9604
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,...
0
10644
Oralloy
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...
0
10379
jinu1996
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...
1
10394
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,...
1
7665
isladogs
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...
0
6882
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();...
0
5552
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...
3
3015
bsmnconsultancy
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.