试图在别处找到这个没有运气的人。
我正在尝试删除磁盘上不再存在但仍显示在SSMS 2014中的对象资源管理器中的数据库
那么我怎样才能“清除它们”的对象资源管理器?
我是否需要从sys.master_files中手动删除它们?
例外是:
Drop failed for Database 'aspnet-Blawblaw-20141027015559'. (Microsoft.SqlServer.Smo)
------------------------------
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=12.0.2000.8+((SQL14_RTM).140220-1752)&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&EvtID=Drop+Database&LinkId=20476
------------------------------
Program Location:
at Microsoft.SqlServer.Management.Smo.SqlSmoObject.DropImpl()
at Microsoft.SqlServer.Management.Smo.Database.Drop()
at Microsoft.SqlServer.Management.SqlManagerUI.DropObjects.DoDropObject(Int32 objectRowIndex)
at Microsoft.SqlServer.Management.SqlManagerUI.DropObjects.DropAllObjects(Boolean stopOnError)
===================================
An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)
------------------------------
Program Location:
at Microsoft.SqlServer.Management.Common.ServerConnection.ExecuteNonQuery(String sqlCommand, ExecutionTypes executionType)
at Microsoft.SqlServer.Management.Common.ServerConnection.ExecuteNonQuery(StringCollection sqlCommands, ExecutionTypes executionType)
at Microsoft.SqlServer.Management.Smo.ExecutionManager.ExecuteNonQuery(StringCollection queries)
at Microsoft.SqlServer.Management.Smo.SqlSmoObject.ExecuteNonQuery(StringCollection queries, Boolean includeDbContext)
at Microsoft.SqlServer.Management.Smo.SqlSmoObject.DropImplWorker(Urn& urn)
at Microsoft.SqlServer.Management.Smo.SqlSmoObject.DropImpl()
===================================
Unable to open the physical file "C:\Projects\BlawBlaw\BlawBlaw\App_Data\aspnet-BlawBlaw-20141027015559.mdf". Operating system error 3: "3(The system cannot find the path specified.)".
File activation failure. The physical file name "C:\Projects\BlawBlaw\BlawBlaw\App_Data\aspnet-BlawBlaw-20141027015559_log.ldf" may be incorrect. (.Net SqlClient Data Provider)
------------------------------
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft%20SQL%20Server&ProdVer=11.00.3000&EvtSrc=MSSQLServer&EvtID=5120&LinkId=20476
------------------------------
Server Name: (LocalDb)\v11.0
Error Number: 5120
Severity: 16
State: 101
Line Number: 2
------------------------------
Program Location:
at Microsoft.SqlServer.Management.Common.ConnectionManager.ExecuteTSql(ExecuteTSqlAction action, Object execObject, DataSet fillDataSet, Boolean catchException)
at Microsoft.Sq
答案 0 :(得分:2)
这对我有帮助。
public static async Task CheckSite(string url, int id) {
try {
using (var db = new PlaceDBContext())
using (var client = new HttpClient(new HttpClientHandler() {
AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip
})) {
client.DefaultRequestHeaders.TryAddWithoutValidation("Accept-Encoding", "gzip, deflate");
client.DefaultRequestHeaders.TryAddWithoutValidation("User-Agent", "Mozilla/5.0 (Windows NT 6.2; WOW64; rv:19.0) Gecko/20100101 Firefox/19.0");
client.DefaultRequestHeaders.TryAddWithoutValidation("Accept-Charset", "ISO-8859-1");
using (var response = await client.GetAsync(url))
using (var content = response.Content) {
client.DefaultRequestHeaders.TryAddWithoutValidation("Accept", "text/html,application/xhtml+xml,application/xml");
var rd = db.RootDomains.Find(id);
string result = await content.ReadAsStringAsync();
if (result != null && result.Length >= 50) {
Console.WriteLine("fine");
rd.LastCheckOnline = true;
} else {
Console.WriteLine("There was empty or short result");
rd.LastCheckOnline = false;
}
db.SaveChanges();
semaphore.Release();
}
}
} catch (Exception ex) {
Console.WriteLine(ex.Message);
using (var db = new PlaceDBContext()) {
var rd = db.RootDomains.Find(id);
rd.LastCheckOnline = false;
db.SaveChanges();
semaphore.Release();
}
}
}
答案 1 :(得分:1)
sqlcmd -S (LocalDB)\MSSQLLocalDB -E -d master -Q "EXEC sp_detach_db 'Test', 'true'"
答案 2 :(得分:0)
“C:\Program Files\Microsoft SQL Server\120\Tools\Binn\sqllocaldb.exe” start “MSSQLLocalDb″
“C:\Program Files\Microsoft SQL Server\120\Tools\Binn\sqlcmd” -S (localdb)\MSSQLLocalDb -E -d master -Q “DROP DATABASE [myDatabase]”
“C:\Program Files\Microsoft SQL Server\110\Tools\Binn\sqllocaldb.exe” stop “MSSQLLocalDb″