如何在installshield express中创建sql数据库? [英] How to create sql Database in installshield express?

查看:111
本文介绍了如何在installshield express中创建sql数据库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近开发了一个具有c#和SQL Server 2008数据访问权限的Winform应用程序.我想为其创建一个"InstallShield express"安装文件(我不想使用ClickOnce或VS中提供了Setup And Deployment女巫).我想在安装SQL Server Express 2008 SP3(不是本地数据库)之后创建数据库或将其附加到SQL Server实例.最好的方法是什么?

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?

推荐答案

您的问题非常模糊,因为您没有解释您使用的是哪种应用",设置文件"或数据库",也没有解释将其附加到sql".将来,请提供这些详细信息.但是,我可以给出一个普遍的答案.

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. 在源项目中创建一个种子数据库,其中包含应用程序的起始数据.
  2. 将种子数据库文件添加到您的项目/解决方案文件中,并将其构建操作"设置为内容".
  3. 确保您的安装程序在部署文件夹(WinForms应用程序的应用程序文件夹)中包含项目内容.
  4. 要从您的应用程序打开种子数据库,请使用诸如Data Source=|DataDirectory|seed.sdf之类的连接字符串.不要尝试搜索您的种子文件或自己设置DataDirectory.安装程序会将DataDirectory设置为内容安装目录.
  5. 请勿尝试写入DataDirectory;安装它的用户可能无法写它.修复该应用程序将覆盖DataDirectory,并同时破坏您保存在其中的所有内容.
  6. 如果需要将数据保存在数据库中,请将|DataDirectory|seed.sdf复制到Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),然后将所有数据读写到副本中.
  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.

有关更多信息,请阅读我对发给 | DataDirectory | 的发帖人的回答,因此不断破坏其用户的数据.

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

这篇关于如何在installshield express中创建sql数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆