Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Basically, my question is "Does this combo work for anyone," and, "Can you see what I am doing wrong"

I have installed 64 bit ODBC driver for sqlite, downloaded from this page. I am running powershell version 2 on window 7. In ODBC configuration I create a system DSN with name LoveBoat, pointing at a valid file. I don't have any "real" apps to test whether the ODBC connection works, but a simple program I list below works. However, with PowerShell, which is what I want:

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

That yields the 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

On the other hand the test 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");
conn.Open();
OdbcCommand comm = new OdbcCommand();
comm.CommandText= "SELECT Name From Myfavoritetable";
comm.Connection = conn;
 OdbcDataReader myReader = comm.ExecuteReader(CommandBehavior.CloseConnection);
 while(myReader.Read())
   {
     Console.WriteLine(myReader[0]);
   }
  }
}
share|improve this question

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.