Friday, February 10, 2012
Support » Support Forum
Register Login
HomeWhat is NDO?- Executive Overview- NDO for DevelopersHow NDO Works- Persistent Classes- Mapping- Queries- Reverse Engineering- Inheritance, Polymorphism- Distributed ApplicationsLicensingSupport- Support Forum- FAQ- Solutions- Downloads- E-Mail Support- Tutorial VideosOnline ShopContact
Welcome to the NDO support forum!
Please register/login at the site if you want to post a thread. We sometimes copy support mails of common interest to the forum. They appear with anonymous sender. Please post your messages in English language if possible. You can do your posts also in German, we will translate your post and our answer so that all users of the forum can read your posts. The forum software requires that javascript is enabled. Please do not insert licence information or licence keys in forum posts. If you know a good answer to a post of another user, feel free to reply! The forum is monitored. We reserve the right to remove posts we consider not to be useful for other forum users.
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