Wednesday, December 17, 2008

Encrypted Free Tables and Visual Studio

I discussed working with encrypted free tables in my November FAQ, however, the topic deserves a bit more detail. The best way to work with encrypted tables with any of the Advantage supported development environments is to use a data dictionary. However, this is not always possible or even desirable.

To use encrypted tables with the Advantage .NET data provider you must specify the encryption password in the connection string and open the table using a TableDirect command type. To open an encrypted table using SQL with the Advantage .NET data provider you must use a database connection. The following code snippet demonstrates opening an encrypted free table.

   1: AdsConnection cn;
   2: AdsCommand cmd;
   3: AdsDataAdapter da;
   4: DataSet ds;
   5:  
   6: string sConnect = "Data Source=C:\\Data";
   7: sConnect += ";ServerType=Remote";
   8: sConnect += ";EncryptionPassword=password";
   9:  
  10: cn = new AdsConnection(sConnect);
  11: cmd = cn.CreateCommand();
  12: cmd.CommandType = CommandType.TableDirect;
  13: cmd.CommandText = "Customer";
  14:  
  15: cn.Open();
  16:  
  17: da = new AdsDataAdapter(cmd);
  18: ds = new DataSet();
  19:  
  20: da.Fill (ds);

You can encrypt and decrypt tables using an Advantage Extended Data Reader which has EncryptTable and DecryptTable methods. To use the extended data reader you must use a CommandType of TableDirect and the ExectueExtendedReader method. To use EncryptTable and DecryptTable you must open the table exclusively by setting the Shared connection string keyword to False.

There is an example application available on the Advantage DevZone which demonstrates these methods. It is listed in Code Central under C#/VB.NET and is called Free Table Encryption Demo. It is a Visual Studio 2005 project which contains C# and VB.NET code.

5 comments:

for IT the said...

Hi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. I am a regular follower of your blog. Really very informative post you shared here. Kindly keep blogging. If anyone wants to become a .Net developer learn from Dot Net Training in Chennai. or learn thru Dot Net Training in Chennai. Nowadays Dot Net has tons of job opportunities on various vertical industry.
or Javascript Training in Chennai. Nowadays JavaScript has tons of job opportunities on various vertical industry.

sakthi said...

Great Article… I love to read your articles because your writing style is too good, its is very very helpful for all of us and I never get bored while reading your article because, they are becomes a more and more interesting from the starting lines until the end.
rpa training in bangalore
best rpa training in bangalore
RPA training in bangalore
rpa course in bangalore
rpa training in chennai
rpa online training

Inigo joseph said...

Really great post, I simply unearthed your site and needed to say that I have truly appreciated perusing your blog entries. I want to say thanks for great sharing.
python Course in Pune
python Course institute in Chennai
python Training institute in Bangalore

jeeva said...

All are saying the same thing repeatedly, but in your blog I had a chance to get some useful and unique information, I love your writing style very much, I would like to suggest your blog in my dude circle, so keep on updates.
microsoft azure training in bangalore
rpa training in bangalore
best rpa training in bangalore
rpa online training

ragini ragini said...

I simply wanted to write down a quick word to say thanks to you for those wonderful tips and hints you are showing on this site.
AWS Training in pune
AWS Online Training