I have installed 64 bit ODBC driver for SQLite, downloaded from this page. I am running PowerShell version 2 on Windows 7.

In the ODBC configuration I create a system DSN with name LoveBoat, pointing to a valid file. I don't have any "real" apps to test whether the ODBC connection works, but the simple C# program with the code below works. I want the PowerShell script to work with it as well.

The test C# program below runs and prints out the expected data:

using System.Data.Odbc;
using System.Data;
using System;

public class program
  public static void Main(string[] args)
OdbcConnection conn = new OdbcConnection(@"DSN=LoveBoat");
OdbcCommand comm = new OdbcCommand();
comm.CommandText= "SELECT Name From Myfavoritetable";
comm.Connection = conn;
 OdbcDataReader myReader = comm.ExecuteReader(CommandBehavior.CloseConnection);

However, the following PowerShell script:

 $x = new-object System.Data.Odbc.OdbcConnection("DSN=LoveBoat")

Yields the following error:

Exception calling "Open" with "0" argument(s): "The type initializer for 'System.Transactions.Diagnostics.DiagnosticTrace' threw an exception."

At line:1 char:8

$x.Open <<<< ()

CategoryInfo : NotSpecified: (:) [], MethodInvocationException

FullyQualifiedErrorId : DotNetMethodException

Basically, my questions are:

  • Does this combination (64 bit SQLite ODBC and PowerShell) work for anyone?
  • Can you see what I am doing wrong?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.