在我的项目appdata文件夹中添加数据库 [英] adding database in my project appdata folder

查看:350
本文介绍了在我的项目appdata文件夹中添加数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Visual Studio中的一个项目上工作...我的项目数据库在sql server中.我想将我的项目数据库放在我的应用程序数据文件夹中.我有一个用于连接数据库的连接字符串

i am working on a project in visual studio...my project database is in sql server. i want to put my project database in my app data folder. i have a connectionstring which i used to connect to the database

public static string connectionString = "Data Source=FAROOQPC\\SQLEXPRESS; Initial Catalog=shop; Integrated Security=True";



在我的项目的appdata文件夹中添加我的项目数据库后,如何更改该连接字符串..



how to change that connection String after adding my project database in appdata folder of my project..

推荐答案

尝试此

try this

AppDomain.CurrentDomain.SetData("DataDirectory", Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData));

<connectionstrings>
  <add name="DATABASENAME">
       connectionString="Data source=DataDirectory|DATABASEFILENAME;"
       providerName="YOURPROVIDERNAME"/>
</add></connectionstrings>



希望这会对您有所帮助



Hope this will help you


"Data Source=FAROOQPC\\SQLEXPRESS; Integrated Security=True;"AttachDbFilename=|DataDirectory|\shopDbFileName.mdf;Initial Catalog=shop"


是否已解决此问题,然后请参阅.....
is this problem is solved then refer me..........


这篇关于在我的项目appdata文件夹中添加数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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