其中AttachDBFilename = | DataDirectory | \ aspnetdb.mdf位于何处? [英] where AttachDBFilename=|DataDirectory|\aspnetdb.mdf is located ?

查看:259
本文介绍了其中AttachDBFilename = | DataDirectory | \ aspnetdb.mdf位于何处?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

其中AttachDBFilename = | DataDirectory | \ aspnetdb.mdf位于哪里?

无法找到位置?它位于何处?

where AttachDBFilename=|DataDirectory|\aspnetdb.mdf is located ?
unable to find location ? where it is located?

推荐答案

它位于Web应用程序的App_Data文件夹中
It is located in App_Data folder of your web application


它位于App_Data目录中。



您可以将AttachDBFilename更改为指向正确的文件夹。



例如AttachDBFilename = C:\\ \\ Database\aspdotnet.mdf
It is located in App_Data directory.

You can change AttachDBFilename to point to the right folder.

For e.g AttachDBFilename=C:\Database\aspdotnet.mdf


看看这里:

http ://stackoverflow.com/a/1409378 [ ^ ]

Have a look here:
http://stackoverflow.com/a/1409378[^]
Quote:

| DataDirectory | 是替换字符串所以你可以单独配置数据库文件的位置。



所以代替:

|DataDirectory| is a substitution string so you can configure the location of your database file separately.

So instead of:

SqlConnection c = new SqlConnection (
   @"Data Source=.\SQLDB; AttachDbFilename=C:\MyDB\Database.mdf;Initial Catalog=Master");



您执行以下操作:


you do the following:

// Set |DataDirectory| value
AppDomain.CurrentDomain.SetData("DataDirectory", "C:\myDB");

// SQL Connection String with |DataDirectory| substitution string
SqlConnection c = new SqlConnection (
   @"Data Source=.\SQLDB; AttachDbFilename=|DataDirectory|\Database.mdf;Initial Catalog=Master");





这篇关于其中AttachDBFilename = | DataDirectory | \ aspnetdb.mdf位于何处?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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