I am mostly new to deployment packages, although I have created a couple, I have not had to worry about deploying a SQL DB with one, until now. I have a C# WPF application that has a SQL Server 2008 express DB that it uses. I don't use it as a file based database, the connectionstring is: Data Source=<MACHINENAME>\SQLEXPRESS2008;Initial Catalog=SRS;Integrated Security=True;Pooling=False
I have already figured out the SQL Server 2008 pre-requisite, so it will get installed properly.
I realize that '<MACHINENAME>' is not normal, but that is how my dev system is set up, '(local)' is a SQL 2005 Express DB.
I have 2 questions: 1) How do I change the connection string to properly point to the correct DB 2) How do I run scripts to create the DB and subsequent tables, OR how can I copy the MDF files to the proper directory?
I understand how to create Custom Actions, but I do not know how to create databases and tables from that. I would prefer to have a bunch of SQL Scripts that it just runs through and executes in the proper order, but if I can get the MDF file in the proper location, that would be far better.
Thanks in advance for your help! Brad
Brad - Edited byWebman Wednesday, June 10, 2009 3:59 PM
-
| | Webman Wednesday, June 10, 2009 3:24 PM | I am not using ClickOnce, I am using an Installer. I want to be able to control more than what the ClickOnce allows me to control. Things like a setup directory, shortcuts, a prompt to give the user a chance to enter a registration key, etc.
I have figured out how to finally get that guys code to work. I tore it down to it's basics, and I need to do some fine tuning. I hope to put a more up-to-date post on it. I am also working out a format that will allow for checking what version of my database the client has, so that I can run scripts to update the database without overwriting the data. Copying the MDF/LDF files is not a good thing to do when you are updating software, and would really not like to overwrite my customer's data. I think that will be bad. LOL
Thanks for everyone's help. It will be awhile until I can post everything I have done, I have to fine tune that application and the installer.
Brad Brad- Marked As Answer byWebman Thursday, July 09, 2009 4:26 AM
-
| | Webman Thursday, July 09, 2009 4:25 AM | Hi Webman,
If you install your database on the same machine where your application is installed, you can use '.' in the connection string to represent the local machine. For example: Data Source=.\SQLEXPRESS2008;Initial Catalog=SRS;Integrated Security=True;Pooling=False
As for your second question, you can backup your database to a file and add the file toyour Setup project. Restore the database on the target machineusing thebackupdatabase filevia a custom action.
Please visit the following link for a sample on how to do it: http://www.codeproject.com/KB/database/Deploy_your_database.aspx
Hope this helps. If you have any question, please feel free to let me know.
Sincerely, Linda Liu
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
end us any feedback you have about the help from MSFT at fbmsdn@microsoft.com. | | Linda Liu Thursday, June 11, 2009 4:47 AM | Linda,
Thanks for that web site and information. I went through and tried to work it out from their example. There were some inconsistencies from VS 2005 to VS 2008. There were also some difficulties with his code. I have tried but can't get it to work. I think it has to do with the 'SQLEXPRESS2008' instance on my development machine, but I am sure I can chase my tail for hours on this. Basically, I run the install package and I get a very generic error message when it is at the DB install process, and his log file is non-existant. If there is a way to step through this type of code, that would be great. Otherwise it is just hit or miss, and we all know how that goes.
This seems to me much more complicated than I originally thought. If you know of any other articles that are more up to date (that one was 2006), I would appreciate it. In the meantime, I will continue to see what else I can find. Brad | | Webman Thursday, June 11, 2009 3:32 PM | Hi Brad, Please refer to the following article on how to debug a custom action when installing: http://harriyott.com/2007/02/debugging-custom-actions-in-visual.aspxHope this helps. Sincerely, Linda Liu
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
end us any feedback you have about the help from MSFT at fbmsdn@microsoft.com. | | Linda Liu Friday, June 12, 2009 4:11 AM | Brad,
I too have a WPF app that I need to install Sql Express 2008 and attach two databases. I want to use clickonce to install my app because of the checking for an update when launched. I noticed from your post that you have figured out how to get the pre-requisite Sql Server 2008 express to install properly and write custom actions. I am new to clickonce and have not idea on how to perform these options. Would you mind sharing how you accomplished the install and custom actions? I have been searching everywhere but all the articles seem out dated.
Thanks, Bryan K | | Krossley Sunday, June 14, 2009 2:35 PM | Bryan,
I am not sure how to do it for ClickOnce. I am not using a ClickOnce deployment. I am using a deployment package project to do everything. In a project you can set it to look for specific applications that your application requires. You right click on the package go to the properties, and there is a button on the bottom of the form (I don't have it in front of me at this point). That is where you click on the requirements.
If you have VS 2008 Express, the packages will already exist for SQL 2008. If not, the easiest way to get them is to download VS 2008 Express, copy the 'WindowsInstaller4_5' and 'SQLExpress2008' packages from the packages folder. (C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bootstrapper\Packages) Uninstall VS 2008 Express (if you don't really need it) and copy those two folders back into the packages directory.
Yes, this seems odd, but it works. It is what I did to get mine to work, and it did work.
I have only used the ClickOnce a couple of times, and I can't think of anyway you can do it using that Deployment.
I know it doesn't give you the answer you are looking for, but I hope it shines some light on the subject.
Brad Brad | | Webman Monday, June 15, 2009 1:09 PM | Brad,
Thanks for the reply. In the package are you also including the sql server 2008 express install file. And is your application update aware and if so how are you approaching application updates? Having a application that checks to see if there is an update automatically out of the box without third party software is really apealing to me.
Thanks, Bryan | | Krossley Monday, June 15, 2009 1:22 PM | I do not have the application checking for updates. But, I believe there is a way to do that, I have not looked into it at this point. Brad | | Webman Monday, June 15, 2009 5:02 PM | Hi Brad,
How about your problem now? If you need our further assistance, please feel free to let me know.
Sincerely, Linda Liu Please remember to mark the replies as answers if they help and unmark them if they provide no help.
end us any feedback you have about the help from MSFT at fbmsdn@microsoft.com. | | Linda Liu Thursday, June 18, 2009 3:18 AM | I am on vacation this week, and have not had a chance to look into the last solution you gave me. I will be back in the office next week. Brad | | Webman Thursday, June 18, 2009 3:00 PM | Hi Linda,
I have been working on this project again. I still cannot get that SQL Server code to work. His code is for VS 2005. I am working in VS 2008. There are too many differences in what he has, and what I need. This article also does not explain very well what he is doing, perhaps if he did that, I would be able to figure out what I need to do from there.
I would also like to know if there is a way to make sure that a specific instance of SQL 2008 is installed, and if not, install it, then put the database there. For example: I have .\MyAppName so that I know I won't run into any issues with other databases. How do I make that work? I know how to check for SQL 2008, but not a specific instance of it.
I am starting to get frustrated at the complexity of doing something that thousands of developers have done, but not much documentation on it (That I can find).
Thanks, Brad Brad | | Webman Monday, July 06, 2009 1:42 AM | You're using ClickOnce, and want to deploy a SQLExpress database? Can't you just select SQLExpress as a prerequisite, attach your database and set "copy to output directory" to "copy if newer" ? Here's another thread that talks about deploying a database with your ClickOnce application: http://social.msdn.microsoft.com/Forums/en-US/winformssetup/thread/c8c55be6-be34-47cf-93fc-6cc0bf97f2cfRobinDotNet Click here to visit my ClickOnce blog! | | RobinDotNet Thursday, July 09, 2009 2:38 AM | I am not using ClickOnce, I am using an Installer. I want to be able to control more than what the ClickOnce allows me to control. Things like a setup directory, shortcuts, a prompt to give the user a chance to enter a registration key, etc.
I have figured out how to finally get that guys code to work. I tore it down to it's basics, and I need to do some fine tuning. I hope to put a more up-to-date post on it. I am also working out a format that will allow for checking what version of my database the client has, so that I can run scripts to update the database without overwriting the data. Copying the MDF/LDF files is not a good thing to do when you are updating software, and would really not like to overwrite my customer's data. I think that will be bad. LOL
Thanks for everyone's help. It will be awhile until I can post everything I have done, I have to fine tune that application and the installer.
Brad Brad- Marked As Answer byWebman Thursday, July 09, 2009 4:26 AM
-
| | Webman Thursday, July 09, 2009 4:25 AM |
|