using SQLServer CE with DAAB

Topics: Data Access Application Block
Mar 25, 2008 at 10:48 AM
I've implemented some sample code for using SSCE with DAAB. It works fine but after reading "To open a database, open a connection to it with the CreateConnection method. This method creates the ‘keep alive” connection. When you are finished using the database, you must explicitly close the “keep alive” connection to the database with the CloseSharedConnection method. There is only one “keep alive” connection for each connection string, although you can have multiple connections open for the same connection string." in entlib documentation, I think I am doing something wrong.

What I'm doing now is using DatabaseFactory.CreateDatabase() method whenever i need to access the database and db.ExecuteNonQuery(cmd), db.AddInParameter() and IDataReader rdr = db.ExecuteReader(dbCommand) for data operations. I've tried CreateConnection & Transaction sample in the documentation but it threw an error saying it doesnt support SSCE. What's the best approach to use SSCE with enterprise lib?

One more question, when I use DatabaseFactory.CreateDatabase(), does it return the database having keep alive connection or should I use singleton pattern (maybe some other kind of approach?) for accessing a single database object in whole application?