如何在asp.net的app_data文件夹中添加现有数据库 [英] How to add existing database in app_data folder in asp.net

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

问题描述

如何在asp.net的app_data文件夹中添加现有数据库?

How to add existing database in app_data folder in asp.net?

推荐答案

1) first of all i have to deattach database from sql server
a) open sql server
b) connect your server
c) open node of database and right click on your database and choose task menu and then choose deattach then database will deattached

2) In second step in visual studio right click on app_data folder and click on add existing item and then select database which you want to add in app_data folder it will be in In my case ( C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\MSSQL\DATA\accountdb.mdf) and now this database will add in app_data folder

3) Now change your connection string in config file
Collapse | Copy Code

<connectionstrings>
        <add connectionstring="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Accountdb.mdf;Integrated Security=True;User Instance=True  " name="ConnectionASPX" providername="System.Data.SqlClient" />
</connectionstrings>




//here |DataDirectory| is path of app_data folder and accountdb is the name of database name can be anything of connectionstring.

Thank You if this solution helps you so please vote for me


所以,您要解决的问题只是继续.
右键单击您的App_Data文件夹,然后单击添加现有项,
然后选择您的数据库即可.

仅当使用SqlServer分离数据库时,给定方法才有效.
要分离数据库,请在Sql Server中转到数据库,然后右键单击它并选择detach选项.
然后在c驱动程序中的某个位置找到数据库:
C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data

一切顺利.
So what is your problem just go ahead.
Right click on your App_Data folder and click on Add Existing Item,
Then select your database and that''s it.

The given method works only when your database is detached with SqlServer.
For detaching the database go to your database in Sql Server and then right click on it and select detach option.
then find your database somewhere in c driver:
C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data

All the best.


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

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