[Mono-list] SqliteConnectionStringBuilder -- Error

fzaleta fzaleta at aol.com
Sun Jun 29 12:27:35 EDT 2008


Hello,

I've search a lot of places to find a solution and/or a reason to this
problem.  I am trying to use the SqliteConnectionStringBuilder to
programmatically build a connection string to a local sqlite database.  The
program builds ok.  However, when I run the program, it gives an exception
when creating the connection.

Unhandled Exception: System.InvalidOperationException: Invalid connection
string
  at Mono.Data.SqliteClient.SqliteConnection.SetConnectionString
(System.String connstring) [0x00000] 
  at Mono.Data.SqliteClient.SqliteConnection.set_ConnectionString
(System.String value) [0x00000] 
  at Mono.Data.SqliteClient.SqliteConnection..ctor (System.String
connstring) [0x00000] 
  at (wrapper remoting-invoke-with-check)
Mono.Data.SqliteClient.SqliteConnection:.ctor (string)
  at ConnStrBuilder.MainClass.Main (System.String[] args) [0x00032] in
Main.cs:28

This only occurs when I use the ConnectionString property of the
ConnectionStringBuilder.  If I use the actual connection information, it
works.  When I print out csb.ConnectionString, it appends "Data Source=" to
the ConnectionString information.  I believe this is what is causing the
problem.  Is this by design or a bug?  

Thanks in advance for any information.

Frank

----------------------------  Program  --------------------------------- 


// Main.cs created with MonoDevelop
// User: freak at 11:31 AM 6/26/2008
//
using System;
using System.Data;
using Mono.Data.SqliteClient;

namespace ConnStrBuilder
{
	/// <summary>
	/// SQLite Connection String Builder Example
	/// </summary>
	class MainClass
	{
		public static void Main(string[] args)
		{
			
			SqliteConnectionStringBuilder csb = new SqliteConnectionStringBuilder();

			//Define connection attributes
			csb.DataSource = "URI=file:products.db";
			csb.Add("version",3);

			//Actualy Connection String
			Console.WriteLine("Connection String:\n{0}", csb.ConnectionString);
			
			//Use ConnectionStringBuilder string to create connection
			SqliteConnection dbConn = new SqliteConnection(csb.ConnectionString); //
<--throws exception	
			//SqliteConnection dbConn = new
SqliteConnection("URI=file:products.sq3,version=3"); // <-- This works
			
			//Open Database Connection
			Console.WriteLine("Connection String:\n{0}", csb.ConnectionString);
			dbConn.Open();
			Console.WriteLine("Database connection State: {0}",dbConn.State);

			//Close Database Connection
			dbConn.Close();
			Console.WriteLine("Database connection State: {0}",dbConn.State);
			
		}
	}
}
-- 
View this message in context: http://www.nabble.com/SqliteConnectionStringBuilder----Error-tp18149207p18149207.html
Sent from the Mono - General mailing list archive at Nabble.com.



More information about the Mono-list mailing list