C# – DataGridView as database frontend

Yesterday I followed a thread on Codepro.vn asking about working with DataGridView. There are 2 questions at this thread:

1. How to get the index of current row of DataGridView?

2. How to add,edit,delete directly on DataGridView?

So I would like to write a small tutorial to answer these questions. To get the index of current row in DataGridView is very simple, we just access the property CurrentCellAddress of DataGridView with the following code:

int nCurrentRow = dataGridView1.CurrentCellAddress.Y;

To answer the second question I would like to “steal” an example of the book “Datenbank-Programmierung mit Visual C# 2005” to explain more about how DataGridView works. The complete source code you can download as following link “DataGridView as database frontend“. For this example, we prepare a Access database with following structure

Then we make a binding connection between the DataGridView and database. When the connection was built, each change on DataGridView will be updated into data source.

BindingSource bs = new BindingSource(); // Create a binding connection
 m_dtExpenditure = CData.getExpenditure(txtDateFrom.Text, txtDateTo.Text); //Get data source
 if (m_dtExpenditure == null)
 dgvExpenditure.DataSource = null;
 tsslStatus.Text = "Access denied";
 bs.DataSource = m_dtExpenditure;
 dgvExpenditure.DataSource = bs; // Build connection between DataGridView and data source


To update the database, we just need to get the changes, update it in the data source and our variable.

DataTable dtChanges = m_dtExpenditure.GetChanges();
 if (dtChanges != null)
 CData.setExpenditure(ref dtChanges);
 tsslStatus.Text = "All changes were saved";
 tsslStatus.Text = "No change to save";

I think this example is pretty easy to understand. To load and edit the data source I use the class DbProviderFactory to manage the connection, command and so on.  There are only two errors that I met during implementing this example. They are:

1. The ‘Microsoft.Jet.OLEDB.4.0’ provider is not registered on the local machine : To solve this error we just change the platform target into 0x86 as following image

2. “Concurrency violation: the UpdateCommand affected 0 of the expected 1 records” . After spending half hour to fix this error I found out that I may be use a keyword as the name of the column. I used “No, DateAndTime, Net ,Gst ,Notice”. Really don’t know which of them caused the error above. I just changed all of them and everything worked.

This example I have extracted from book “Datenbank Programmierung mit Visual C# 2005”.

C# – How to edit resource of an assembly?

Maybe because of a weird requirement, we have to edit a resource of a compiled assembly. We can’t edit an embedded resource directly but only replace it with the new one. In .NET project, there are two ways to add a resource : through Resources.resx in project settings tab or setting a file as embedded resource in Visual Studio. In this post, I’ll show you how to replace an embedded resource of an assembly with Mono.Cecil.

Continue reading C# – How to edit resource of an assembly?

How to unpack .Net Reactor?

Today I decide to write a tutorial about unpacking .Net Reactor. This is a first time I make a video tutorial. I hope that’s ok. Please feedback to me if you have questions or want to comment for my tutorials. Use Internet Explorer to open .swf files, you’ll get a better view than using Firefox.
Download tutorials:

Dedot – A deobfuscator for Dotfuscator

Dotfuscator is the single most widely deployed obfuscation solution on .NET and every other platform combined. And Dedot is a tool which tries to do against what Dotfuscator does. It’ll be helpful in some cases if you loose your project and have only binary files, or you want to analyze some viruses,…
After decryption, a patched assembly with decrypted string will be saved at the same folder of the application. Use Reflector to see result.
This tool will be updated soonly with more functions. Now it’s on BETA version. Use it on your risk. I’ll do it when I have more time.

  • Requirements : .NET Framework 2.0
  • Version:
  • Supported Version of Dotfuscator
    • 4.2
    • before 4.2 (not sure)

Want more functions. Post a comment directly under.


  • If this tool doesn’t work with your packed assembly, send it to me. DO NOT blame me if this one doesn’t work. I’m just a newbie.
  • The Anti-obfuscate flow control doesn’t work good. Use it on your risk. My recommend is “Don’t use this option.

LINK DOWN: When you want to post this tool to somewhere. Please post url to my site, that keeps update for this tool when you do that.

Link down: http://hintdesk.com/Web/Tool/DeDot.zip


  • [ –] : Fix minor bug.
  • [] : Anti-Flow-Control-Obfuscation was implemented successfully.
  • [] : Fix some bug at decrypting Unicode String
  • [] : BETA Version.

Dedot screenshot

UPDATE 31.03.2012
Source : http://hintdesk.com/Web/Source/DeDotSource.zip