startup problem

startup problem

Old forum URL: forums.lhotka.net/forums/t/2031.aspx


Rhiga Mortis posted on Tuesday, December 26, 2006

I am trying to setup the Project Tracker example, but am getting the newb error:

Csla.DataPortalException: DataPortal.Fetch failed (System.Data.SqlClient.SqlException: An attempt to attach an auto-named database for file C:\CSLA 2.0\csla20\ProjectTracker20cs\Security.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.
   at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) etc.

I have followed all the instructions. I set up a new identity with administrator group privledges, set up the COM+ root as explained in Chap 12, but upon login attempt, get the above error.

My laptop is imaged by my university with Visual Studio 2005 Professional and Sql Server 2005, so I had to install Sql server 2005 Express for the CSLA example. I can view the database in Visual Studio, but not in SQL Server Management Studio.

Does anyone have an idea what the problem might be? I am very appreciate of any help on this issue.

Thank you!

tiago replied on Thursday, December 28, 2006

No need for SQL 2005 Express.

1-Just attach the PTracker and Security databases to SQL 2005

2-Correct the connection string on these files:
ProjectTracker20cs\EnterpriseServicesHostcs\application.config
ProjectTracker20cs\PTWin\app.config
ProjectTracker20cs\www\PTWeb\web.config
ProjectTracker20cs\www\PTWebService\web.config
ProjectTracker20cs\www\RemotingHost\web.config
ProjectTracker20cs\www\WebServicesHost\web.config

3-Sample connection string:
connectionString="Server=192.168.1.1;Database=PTracker;User=sa;Password=password"

Rhiga Mortis replied on Friday, December 29, 2006

Tiago, thanks for your response.

Rocky, this experience was extremely frustrating. I bought your book, but I wanted to run the demo/example project before I was an expert on CSLA. If I were an expert on SQL Server, I guess this would have gone much smoother. Or had there been some write-up on how to attach to an mdf file via SQL Server Management Studio, which I had never had to do before.

For anyone else just starting out with CSLA and using SQL Server, here was the problem I encountered:

The two mdf files, independent of where you locate them, have names like:

C:\VISUAL STUDIO PROJECTS\CSLA20\PROJECTTRACKER20CS\SECURITY.MDF

These names seem to be embedded in the files, and I am guessing they foiled every connection string variation I tried with CSLA. I was able to start up a new Windows Form project and connect to the databases, but using the same connection string with CSLA caused DataPortal.Fetch errors.

Eventually, I noticed that SQL Server Management Studio had an option to attach a database file, but I was unable to attach because the files I had been working with were constantly locked by some other process.

Finally, I rebooted, and started over with CSLA. Once I expanded the files to a new directory, I was able to successfully attach to them from within SQL Server Management Studio, and I changed their names from the long string shown above to PTSecurity.mdf, and PTracker.mdf. Then I started up a new Windows forms project, connected successfully to the databases via Add New DataSource, and got the following connection strings which worked for me (YAY!):

            connectionString="Data Source=localhost;Initial Catalog=PTRACKER.MDF;Integrated Security=True"
and

            connectionString="Data Source=localhost;Initial Catalog=PTSECURITY.MDF;Integrated Security=True"

Now that I have them working, I get to play with them a bit. I am hoping to use them in my next project team at school, but I will have to understand how to use them much better so I can sell the rest of the team on their practicality.

Good luck all, code well :)

Rhiga Mortis

fuzzboxUK replied on Tuesday, January 02, 2007

Hey Rhiga nice one! (and Tiago, sorry...) Smile [:)]

You saved me a lot of time  Big Smile [:D]

I do agree with you, Authors do tend to forget that simple things can trip-up a reader. I have found this on countless books. It can be very frustrating indeed. Angry [:@] I think that more attention needs to be given in areas like this.  This can be done quite easily with a list of required software tools and or tips and tricks. The best way is to give the code to a novice and monitor the performance or questions as they try to get started. Possible?

I have read the first seven chapters and moved onto Chapter 8 a day and half ago, where I have been struggling to get it to work. I did cheat with the app.config - using the "Windows" authorisastion, but I wanted to get the application woking out-of-the-box as it were.

However, I do like the book it is well written and informative and I'm about to use the CSLA framework on a very high profile project if the Proof of Concept works of course. Angel [A] Wink [;)]

Cheers Sleep [|-)]

derekliang replied on Monday, January 22, 2007

check the web.config for app.config for the connection string that you are using to connect to database.

Copyright (c) Marimer LLC