300x250 AD TOP

Text Widget

Total Pageviews

Subscribe us

Contact Us

Name

Email *

Message *

Powered by Blogger.

You can also receive Free Email Updates:

Popular Posts

Followers

Thursday, 14 June 2012

Tagged under: , ,

Connecting C# to MySQL database / C# connection String for MySQL

In many cases it becomes imperative to connect C# to MySql, the prominent reason being the inherent simplicity of MySql. We have generally used the usual connection string to connect PHP to MySql. Connecting C# to MySql is similar.
We first need to use the connection string to establish the connection with MySql. Then, we use the SQL queries to carry out the Creation, Insertion, Update & Delete operations.


Before we do anything, first you need to download and install mysql-connector. You can get this connector from MySQL :: Download Connector/Net.

Once you install this connector, you need to add it as a reference in your C# project. You can do this by navigating to Project -> Add Reference. Then go to the .Net tab, and search for MySql.Data, and add it as a reference.

Now you need to include MySql.Data.MySqlClient at the start of the code. Add this at the start:


Now, you can use this connection string for establishing the connection:


Now, you can use 'con' when you need to fire any query.

Now, lets get into details of using sql queries.

1. CREATE TABLE:

                 
2. INSERT:

                 
3. UPDATE:

                 
4. DELETE:


5. SELECT:


Finally, you need to close the connection, after you finish executing the queries. You can do this by writing:
                 


Friday, 1 June 2012

Tagged under: , , ,

Generating a Unique Hardware Fingerprint for Software Licensing

Generating a hardware fingerprint is the most commonly sought technique to ensure security in case of softwares. There can be various methods of generating the hardware fingerprint, using different languages. However, the important thing to decide is, which devices to consider while generating the fingerprint.

For licensing purposes, the best and secure way is to generate a unique key for the client's machine and provide a corresponding license key for that key. The key can be generated using the unique id of the client's computer motherboard, BIOS and processor. When you get these IDs, you can generate any key of your preferable format.


In this post, I will get into the details of generating the unique fingerprint for the user's system.


Step I: Adding References:


First of all, you need to add the following references to your project.
1. System.Drawing
2. System.Management
3. System.Windows.Forms
For doing this, navigate to Project in the Menu Bar--> Add References-->.Net


Step II: Starting to Code


Add the following code at the start.


Now, you can use this unique hardware fingerprint in further hashing, to authenticate the user system!!



You can for further assistance.