How to create sql Database in installshield express?

谁都会走 提交于 2020-01-07 09:14:48

问题


I recently developed a winform application with c# and SQL Server 2008 data access. I want to create an "InstallShield express" setup file for it (I don't want to use ClickOnce or Setup And Deployment witch is available in VS). I want to create a db or attach it to SQL server instance after installing SQL Server Express 2008 SP3 (not local db). What is the best way to do this?


回答1:


Your question is quite vague as you do not explain what kind of “app”, “setup file” or “db” you are using, nor how you “attach it to sql”. In the future, please include these details. However, I can give a general answer.

  1. Create a seed database, that contains the starting data for your application, in your source project.
  2. Add the seed database file to your project/solution file and set its Build Action to “Content”.
  3. Ensure your installer includes project content in the deployment folder (the application folder for WinForms apps).
  4. To open the seed database from your app, use a connection string like Data Source=|DataDirectory|seed.sdf. Do not try to search for your seed file or to set DataDirectory yourself; the installer will set DataDirectory to the directory your content was installed to.
  5. Do not try to write to DataDirectory; it may not be writable by the user who installed it. Repairing the app will overwrite DataDirectory, destroying anything you saved there, as well.
  6. If you need to save data in the database, copy |DataDirectory|seed.sdf to Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), then read and write all data to the copy.

For more information, read my answer to a poster who wrote to |DataDirectory| and therefore kept destroying his user's data.



来源:https://stackoverflow.com/questions/32318584/how-to-create-sql-database-in-installshield-express

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!