I am running Win 7 64, the latest PostgreSQL 64 bit, and I installed the 64 bit ODBC driver (0310-64). Using the two ODBC control panels, I can create both a 32 and a 64 bit connection. Both test ok.
In VS 2010 Express, I installed MS's ODBC driver 1.0.4030.0. I can connect to the 32 bit DSN, but the 64 bit one gives the the architecture mismatch error.
This doesn't make sense because I set up the 64 bit DSN on the 64 bit ODBC control panel, where I was given 64 bit PG as an option (unlike on the 32 bit CP). I selected the UNICODE version.
To make it work with 64 bit DSN and Visual C# 2010 Express Edition edit project settings file .csproj (e.g. WindowsFormsApplication1.csproj) and set PlatformTarget property to x64:
<PlatformTarget>x64</PlatformTarget>
Futhermore you don't need to install Microsoft ODBC .NET Data Provider driver externally, because it's included in .NET as System.Data.Odbc
namespace.
Example:
private void button1_Click(object sender, EventArgs e)
{
OdbcConnection cn = new OdbcConnection("dsn=PostgreSQL35W");
OdbcCommand cmd = new OdbcCommand("SELECT version()", cn);
cn.Open();
richTextBox1.AppendText(cmd.ExecuteScalar().ToString());
cn.Close();
}
Result:
Also consider use of Npgsql instead. It seems to be pretty common PostgreSQL interface for .NET.