Nice way to call a private method in C# without using “reflection”

 

http://elegantcode.com/2010/01/28/calling-non-public-methods/

 

// Calling code that uses delegates

var subject = new Subject();

var doSomething = (Func<String, String>)

Delegate.CreateDelegate(typeof(Func<String, String>), subject, "DoSomething");

Console.WriteLine(doSomething("Hello Freggles"));

 

Note that this only works for instance methods and not for static methods.

How to connect to MySQL by using ADO .NET and C# 4.0

Download the MySQL drivers at: http://dev.mysql.com/downloads/connector/net/

Install the drivers on you’re development machine.

 

At references to:

– System.Data

– MySql.Data [C:\Program Files (x86)\MySQL\MySQL Connector Net 6.4.3\Assemblies\v4.0\MySql.Data.dll]

 

The following code will output all database names to the console window:

using System.Data;
using MySql.Data.MySqlClient;
string connectionString = String.Format("Server={0};Port={1};Database={2};Uid={3};Pwd={4};",
"192.168.1.1", "3306", "MyDatabaseName1", "MyUserName1", "MyPassword1"); using (MySqlConnection connection = new MySqlConnection(connectionString)) { using (MySqlCommand cmd = new MySqlCommand("SHOW DATABASES", connection)) { connection.Open(); MySqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { Console.WriteLine(reader.GetString(0)); } } }

Books tab not showing after installing iBooks 1.3 on iPhone 4

After installing iBooks 1.3 on my iPhone 4, I did not see the Books tab in iTunes. Even after restarting iTunes and my iPhone 4 the Tab would not show.

I e-mailed a PDF to myself and from the e-mail I added the PDF to the iBooks app on my iPhone 4 after restarting my Windows 7 x64 machine I was able to see the books tab in iTunes, don’t know if rebooting the Windows 7 machine would solved the problem without adding the pdf from the e-mail to the iBooks app:

 

image

Creating a database diagram showing only the keys in Microsoft SQL Server Management Studio 2008 R2

If you have a large database and want to create a database diagram showing only the keys, this is possible by using the Microsoft SQL Server Management Studio:

In this example I used the Advantureworks 2008 R2 example database:

 

  • Open Microsoft SQL Server 2008 R2 Management Studio and connect to the AdventureWorks database (http://msftdbprodsamples.codeplex.com/)
  • Right click Database Diagrams and choose [New Database Diagram]

 

image

 

  • Add all tables to you’re diagram, by selecting all tables clicking Add and then click Close

image

 

  • Select all tables by pressing Ctrl + A

image

 

  • Right click a table and click Table View > Keys

 

image

 

Result

image