An attempt to attach an auto-named database for file
在用VS自带的 .mdf读取(joint)时,报错:
Server Error in '/' Application.
An attempt to attach an auto-named database for file F:\cs\office\ReadWriterOffice\ReadWriterOffice\App_Data\Database.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Data.SqlClient.SqlException: An attempt to attach an auto-named database for file F:\cs\office\ReadWriterOffice\ReadWriterOffice\App_Data\Database.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share. Source Error: Line : DB db = new DB("DBConnectionString");
Line : using (SqlConnection conn = new SqlConnection(db.ConnectionString)) {
Line : conn.Open();
Line : using (SqlCommand cmd = conn.CreateCommand()) {
Line : cmd.CommandText = sql; Source File: F:\cs\office\ReadWriterOffice\ReadWriterOffice\Samples\TransmitLonLa.aspx.cs Line: Stack Trace: [SqlException (0x80131904): An attempt to attach an auto-named database for file F:\cs\office\ReadWriterOffice\ReadWriterOffice\App_Data\Database.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.]
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning() +
System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +
System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK) +
System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, SqlConnection owningObject) +
System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, TimeoutTimer timeout) +
System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, TimeoutTimer timeout, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance) +
System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance) +
System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection) +
System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options) +
System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject) +
System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject) +
System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) +
System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) +
System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +
System.Data.SqlClient.SqlConnection.Open() +
ReadWriterOffice.Samples.TransmitLonLa.ExportExcel() in F:\cs\office\ReadWriterOffice\ReadWriterOffice\Samples\TransmitLonLa.aspx.cs:
ReadWriterOffice.Samples.TransmitLonLa.Page_Load(Object sender, EventArgs e) in F:\cs\office\ReadWriterOffice\ReadWriterOffice\Samples\TransmitLonLa.aspx.cs:
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +
System.Web.UI.Control.OnLoad(EventArgs e) +
System.Web.UI.Control.LoadRecursive() +
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) + Version Information: Microsoft .NET Framework Version:4.0.; ASP.NET Version:4.0.30319.1
解决方案是将连接字符串中的"AttachDbFilename"指定为绝对目录.
经过测试,我发现不是(joint)特殊,其实普通的select语句也会报一样的错,我猜想原因是sql比较特殊,这里应该是找不到,因为我的数据库比较大,所以我是从别的地方拷贝过来的,应该是日志文件不一致.所以需要制定绝对路径.
An attempt to attach an auto-named database for file的更多相关文章
- Attempt to fetch logical page (...) in database 2 failed. It belongs to allocation unit xxxx not to xxx
今天一个同事说在一个生产库执行某个存储过程,遇到了错误: Fatal error 605 occurred at jul 29 2014 我试着执行该存储过程,结果出现下面错误,每次执行该存储过程,得 ...
- Odoo Auto Backup Database And Set Linux task schedualer
First ,Write Database Backup Script: pg_dump -Fc yourdatabasename > /home/yourfilepath/yourdataba ...
- 什么时候会刷新备库控制文件refresh the standby database control file?
通过合理的设置,对于Primary的绝大数操作,都是可以传递到Physical Standby,datafile的操作是通过STANDBY_FILE_MANAGEMENT参数来控制的,但是即使STAN ...
- backup, file manipulation operations (such as ALTER DATABASE ADD FILE) and encryption changes on a database must be serialized.
昨天在检查YourSQLDba备份时,发现有台数据库做备份时出现了下面错误信息,如下所示: <Exec> <ctx>yMaint.ShrinkLog</ctx> ...
- ArcCatalog连接ArcSDE连接报:unable to create new database connection file,permission is denied
参考博文:链接 ArcCatalog连接ArcSDE连接报:unable to create new database connection file,permission is denied 最近经 ...
- SharePoint Config database Log file too big – reduce it!
SharePoint Config database logs are one thing to keep an eye on since they do have a tendency to gro ...
- AdventureWorksDW2008R2 attach: Unable to open the physical file. Operating system error 5: "5(Access is denied.)
http://stackoverflow.com/questions/26014133/adventureworksdw2008r2-attach-unable-to-open-the-physica ...
- attempt to write a readonly database错误的解决(C#,SQLite)
今天打包WPF程序,安装后总是打不开,查看监控日志原来是SQLite的问题,报错如图 当向SQLite数据库中存入新纪录时总是显示attempt to write a readonly a datab ...
- 【原】Configuring Oracle Data Guard In Physical Standby Database
作者:david_zhang@sh [转载时请以超链接形式标明文章] http://www.cnblogs.com/david-zhang-index/p/5042640.html参照文档:https ...
随机推荐
- sqlserver 进行MD5加密
官方定义函数: HashBytes ( '<algorithm>', { @input | 'input' } ) <algorithm>::= MD2 | MD4 | MD ...
- Scut:脚本引擎
Scut 可以执行 C#.Python.Lua 三种类型的脚步,Scut 是如何加载并传递参数的呢? 首先值得注意的是:Scut 在编译时就会将逻辑层脚本源码复制到bin/Script的目录下. 1. ...
- 尝试跑一跑Scut
前段时间都在用 IIS+WCF+Redis+MSSQL 的框架做服务器,前段时间看到了 Scut 的开源框架,整个架构还是蛮干净整洁的... 今天抓来跑一跑. 按照教程安装好所有的环境,版本是6.7. ...
- 关于-webkit-tap-highlight-color的一些事儿
这个属性只用于iOS (iPhone和iPad).当你点击一个链接或者通过Javascript定义的可点击元素的时候,它就会出现一个半透明的灰色背景.要重设这个表现,你可以设置-webkit-tap- ...
- C语言字符数组越界现象
今天在用C的过程中发现一个奇怪的现象.代码如下: ]; chs[] = 'a'; chs[] = 'b'; printf(]); 结果 输出 是 a. 在网上查了一下.有个网友是这样回答的: “ 我 ...
- JS基于时间戳写的浏览访问人数
Title:JS基于时间戳写的浏览访问人数 --2013-12-23 14:07 <script language="JavaScript"> var timesta ...
- linq 的Distinct 扩展方法.
List<miniclass> classs = new List<miniclass>(); classs.Add(new miniclass() { token = &qu ...
- 使用Thumbnails对一个文件夹下的所有图片进行压缩处理
public static void compressPic(){ try { Thumbnails.of(new File("/home/y/my_temp/ydbg-xy-pic&quo ...
- Qt for Android 开发大坑123
http://blog.csdn.net/qyvlik/article/details/50989685 http://blog.csdn.net/qyvlik/article/details/515 ...
- 点击itemView选中checkbox
在Listview中如果item中含有checkbox会使itemview的setonitemchecklistingner失效,我们可以通过设置checkbox的clickbale的值为false来 ...