Tuesday, January 06, 2009
Support » Support Forum
Register Login
Hi Gerhard,
if I understand you right, your application opens several copies of your database residing in different files. I don't know exactly, what happens there, but I guess, that you run into this problem because of the ADO.NET connection pooling. NDO closes all connections as soon as possible (at least after calling pm.Save()), but the connection may remain open and is put into a connection pool by ADO.NET. Since I'm not in the office today, I can't investigate in this question immediately. My suggestion for you is to look for ways to manipulate the connection pooling for your Sql Server.
I try to investigate in this problem right after I'm coming home and let you know, what I can find out.
Best regards:Mirko
good news for you. I tried to do what you described and it works. I did the following:
1. I created a database in Sql Management Studio. In the New Database Dialog you have the possibility to change the path where the database files should be created. Per default they will be created in C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA, where the beginning of the path is the installation directory of Sql Server 2005.2. I disconnected the database from the Sql Server. Right click at the new database entry, choose "Tasks" and choose "Disconnect" (Trennen). Without disconnecting the database, Step 3 wouldn't work.3. Using the Windows Explorer I made a copy of the database files (NDOMultitest.mdf -> NDOMultitest2.mdf, NDOMultitest.ldf -> NDOMultitest2.ldf).4. I wrote the following app:
static string dbName;static void WriteToDb(){ PersistenceManager pm = new PersistenceManager(); pm.RegisterConnectionListener(new OpenConnectionListener(OnNewConnection)); // Constructing objects SnmpSession sess = new SnmpSession(); sess.Port = 162; pm.MakePersistent(sess); //... pm.BuildDatabase(); pm.Save();}static void Main(string[] args){ dbName = @"c:\Temp\NDOMultitest.mdf"; WriteToDb(); dbName = @"c:\Temp\NDOMultitest2.mdf"; WriteToDb();}static string OnNewConnection(NDO.Mapping.Connection conn){ return "Integrated Security=SSPI;Persist Security Info=False;Data Source=localhost;Initial File Name=" + dbName;}
As you can see, WriteDb writes into both databases using the same program.
Best Regards:Mirko