Showing posts with label deployment. Show all posts
Showing posts with label deployment. Show all posts

Thursday, March 29, 2012

Embedded SQL Server Express Deployment - Unhandled Exception: Database already exists

Good Afternoon.

I am trying to write a short application within which I would like to embed a SQL Server Express database, all of which would be deployed via ClickOnce through a web site. The installation process seems to be working without trouble, including installation of the .NET Framework 2.0 and SQL Server Express 2005.

When the application launches on the new machine, however, I get a big Microsoft .NET Framework "Unhandled exception" error dialog box that indicates the database already exists and that the database file could not be attached. I am working with a clean virtual machine that I know has never had the database installed on it.

I fear I am overlooking something quite straightforward, but since this is the first time I have ever attempted to build a data-bound application, I am not sure where I am going wrong.

Perhaps the source of the problem, or a related problem, might be revealed even when I run the application in debug mode from within Visual Studio. I can run the application once, but if I try to run it again, I get an error when I try to open the database connection that is similar in content (database already exists...could not attach). I can run the SSEUtil and detach the database and then run the application again in debug mode and it works no problem (the first time!).

Lastly, if I install the application on the machine on which it was developed and make sure the database is detached, it will run without any trouble (even repeatedly). But, on a new blank machine, there is no database listed that matches my database name, so I cannot try to detach anything!?

My apologies for such a novice question!

Sean

Hi Sean,

I would suggest removing the ‘Initial Catalog’ keyword from your connection string. Among the things that are stored about a database when it is attached is the Name/Path pairing; SQL Server gets a little upset if you try to attach a database using an existing name but with a different path. Enter the |DataDirectory| macro…

I’m guessing you’re using ClickOnce deployment for this application. There are things that will cause the install directory of a ClickOnce deployment to move, when this happens, VS magically fixes up things as far as the application goes, but it cannot fix up the fact that SQL Server has recorded your explicit database as being linked to the old file location. When you attempt to open the application now, the attach fails because there is already a database named JMU_2007 listed in the master database, but it is associated with a different path, so you get the error that the database already exists. I’m guessing this is the problem you’re hitting.

By removing the ‘Initial Catalog’ keyword, you’re forcing SQL Express to give the database an autoname based on its path. If the database moves as a result of VS behavior, the name will be changed because the path has changed, so it will appear to be a different database from the SQL perspective. Hopefully this helps.

Mike

|||

Thanks very much Mike. That did the trick...I can't believe I overlooked that after spending too much time trying to fix this problem.

Sean

Tuesday, March 27, 2012

embedded deployment sql server express

Hi,my problem is the following

I can not completely understand how to deploy sse with my application

To some degree I understand the explaning in Mikes Documentation

Things I don't get:

1)Do I not check the prerequisite server express because when I did and run the setup.exe that I build the thing that happens is that the sql package gets unpacked over and over along with a little message that it's taking a little longer then expected. I gues this is the fallpit where the actual setup.exe for sse is nothing being done with hence the wrapper.

A quote from Mikes document "If the VS Bootstrapper isn't flexible enough for you then". Well, I don't know what I'am doing wrong but it doesn't work at all. I had no problem with the other prerequisites (Framework, installer)

Back to the first question: if so do I manually add the SQLEXP.EXE (downloaded from the internet) or is it the sqlexpr32.exe in the same folder as the setup.exe for the application?

2) How is the wrapper invoked? I don't see that mentioned. I thought when you start the application itself, but that hardly seems logical.

Please anyone, give me some clear directions or additional expanatory

Thanks,

Richard

Hi Richard,

I've never heard of the problem you are encountering where the package gets unpacked over and over. You should test if this is specifically related to how the VS Bootstrapper is calling the package by trying to manually install SQL Express on the problem computer. Try copying the SQLEXPR32.EXE file from the folder where you setup.exe lives to the computer and just double-click on it directly to do a manual install.

Is this problem happening on more than one computer? This seems like it is going to be machine specific and is related to some configuration on the computer that we don't know about. Test your installation on a few other computers to see if the problem can be reproduced.

As far as calling the wrapper, normally the wrapper is what you run and it calls other things. Basically, a wrapper would call the SQL Express installation and then it would call the installation of your custom application. The wrapper replaces your current setup.exe program, which is actuall a wrapper as well. I don't think you need to write a customer wrapper since the problem here is how the SQL installer is executing, you need to figure out if the SQL installer problem is machine specific or not first.

Mike

|||

thanks for the reply,

on it's own it installed fine, but now I'am in the process of uninstalling it and I can't seem to get rid of it. ADD/REMOVE progams doesn't work. Any suggestions?

Anyway I'am going to assume that the deployment is suppose to work fine like you said. That's why I go forward and ask you the question how you can make the prerequisites do a silent install. In particulary the sse. I don't realy grasp the concept off passing arguments to the setup program. How and from where is that code beiing executed?

Before I am going to ask you the shirt of your back I wanted to know what a good book is to learn the concepts of working with sse and a desktop application. Would you suggest ADO.net the core essentials from microsoft press?

Richard

|||

as I stated in my last reply, I deployed my application to my newly installed xp pro laptop

Now, that I want to testdrive my database application I get this error:

An attempt to attach an auto-named database file c:/program files........................\MyDB.mdf failed. A database with the same name exists, or specified file can not be opened, or it is located on UNC share.

This is what I read in my app.config file;

<connectionStrings>

<add name="MasterDetail.My.MySettings.MyDBConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\MyDB.mdf;Integrated Security=True;User Instance=True"

providerName="System.Data.SqlClient" />

</connectionStrings>

What could I be doing wrong?

Richard

|||

Richard777 wrote:

I can't seem to get rid of it. ADD/REMOVE progams doesn't work. Any suggestions?

Odd, it's always worked for me. SQL Server uses a single ARP entry for all copies of SQL Server 2005, this includes multiple Editions and Instances. You need to ensure that you uncheck all the components you wish to remove once you've selected the instance you want to remove. There are also some components that have to be removed separately; I recall that the Setup Components are one of them, but I can't recal the others.

Richard777 wrote:

Anyway I'am going to assume that the deployment is suppose to work fine like you said. That's why I go forward and ask you the question how you can make the prerequisites do a silent install. In particulary the sse. I don't realy grasp the concept off passing arguments to the setup program. How and from where is that code beiing executed?

If you are using ClickOnce to deploy SSE it should already be doing a quite install for the prerequisites. The arguments for each prerequsite are part of the manifest for that prerequiste that is installed by VS. If you are trying to write your own command line you need to use the /qn argument to cause a quite install. There is more information about configuring SSE during install in the FAQ that you can find at the top of this forum.

Richard777 wrote:

Before I am going to ask you the shirt of your back I wanted to know what a good book is to learn the concepts of working with sse and a desktop application. Would you suggest ADO.net the core essentials from microsoft press?

I've not read that book specifically. I have been through part of ADO.NET 2.0 Step by Step and it seems alright. There are also many learning videos available for free on the Microsoft web site, start here (C# or VB.NET) to see if there is anything interesting to you. You might also be interested in the ADO.NET sections of the MSDN Library, which is here.

Mike

|||

Is there anywhere we can get a description of "the manifest for that prerequiste that is installed by VS"

I would like to specify the ADDLOCAL and SQL Signon stuff. Do you have any examples of how to make and include a manifest for these things.

Thanks

Ciaran

|||

Hi Ciaran,

There are a number of documents on MSDN that discuss the Bootstrapper:

http://msdn2.microsoft.com/en-us/library/aa730839(vs.80).aspx
http://msdn2.microsoft.com/en-us/library/ms165429(VS.80).aspx
http://msdn2.microsoft.com/en-us/library/ms229223(VS.80).aspx
http://msdn.microsoft.com/msdnmag/issues/04/10/bootstrapper/

Those documents will tell you enough to read the manifests that are installed by VS, we don't have specific documentation on the individual manifests, but they're XML, so they're pretty much self documenting.

Mike

Thursday, March 22, 2012

email task and file system deployment

does email task only work with sql server deployment? I have an email task in my ssis package and i want go for file system deployment.

thanks,

kushpaw

It should work on both deployments.
I use file system deployment and get all emails successfully

Monday, March 19, 2012

Email Notification with Custom Attachments using Notification Services 2005

Hi All,

I am using Notification Services 2005.I have done with the configuration and deployment of Notification Services 2005.Now i wanted to know how to send notifications via email with custom attachments.

Please help me out in this issue.

Amby

Hi Amby -

[copied for a reply to your newsgroup posting]

The built-in SMTP delivery protocol doesn't support attachments. But
you do have a couple of options:

1) you can build a custom delivery protocol that uses SMTP to send
notifications with attachments. I don't have Shyam Pather's SQLNS book
in front of me at the moment, but I think he goes through a similar
example in it. It's for v2.0, not 2005, but the same concepts should
apply.

2) I've also sent notifications via SMTP that have a link to a
resource that they need rather than including it as an attachment. For
example, rather than attaching a PDF, I place the PDF on a web site
and then send a link to the PDF in the notification. This has worked
well for me.

HTH....

--
Joe Webb
SQL Server MVP
http://www.sqlns.com

~~~
Get up to speed quickly with SQLNS
http://www.amazon.com/exec/obidos/tg/detail/-/0972688811

I support PASS, the Professional Association for SQL Server.
(www.sqlpass.org)