2009-05-11 2 views
0

나는 성 ActiveRecord 예외 문제를 지금 해결하려고 노력했습니다. 데이터베이스에 액세스하려고하면 InnerException 값이 "An attempt to attach an auto-named database for file database.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share." 인 예외가 발생합니다.캐슬 활성 레코드 : SQL Express가 작동하지 않습니다. SQL Developer 않습니다

SQL Server Express 2005 데이터베이스에 연결하려고합니다. 학교 컴퓨터에는 SQL Express 만 있기 때문에 다른 데이터베이스 옵션은 없습니다.

내 연결 설정

hibernate.connection.driver_class 
    NHibernate.Driver.SqlClientDriver 

hibernate.dialect 

    NHibernate.Dialect.MsSql2005Dialect 
hibernate.connection.provider 
    NHibernate.Connection.DriverConnectionProvider 

hibernate.connection.connection_string 
    Data Source=.\SQLExpress;Integrated Security=True;User Instance=True;AttachDBFilename=database.mdf 

이 내가 절대 경로 인 AttachDBFilename를 설정 한 경우에도 작동되지 않습니다. 사용자 인스턴스는 아무 효과가 없습니다. 데이터베이스 파일은 현재 내 WinForms 클래스와 혼합 된 프로젝트의 루트에 있습니다.

hibernate.connection.connection_string 
    Data Source=localhost;Initial Catalog=FinalApp;Integrated Security=True;Pooling=False 

를 사용하여 내가 아무런 문제가 내 노트북에이 일이 없다하지만 난 학교 컴퓨터에 SQL Server 2005의 개발자 버전을 사용할 수 없습니다.

전체 스택 추적

Castle.ActiveRecord.Framework.ActiveRecordException was unhandled 
    Message="Could not perform FindAll for Book" 
    Source="Castle.ActiveRecord" 
    StackTrace: 
     at Castle.ActiveRecord.ActiveRecordBase.FindAll(Type targetType, Order[] orders, ICriterion[] criteria) in c:\dev\castle\svn\branches\1.0.x\ActiveRecord\Castle.ActiveRecord\Framework\ActiveRecordBase.cs:line 1022 
     at Castle.ActiveRecord.ActiveRecordBase.FindAll(Type targetType) in c:\dev\castle\svn\branches\1.0.x\ActiveRecord\Castle.ActiveRecord\Framework\ActiveRecordBase.cs:line 982 
     at Castle.ActiveRecord.ActiveRecordBase`1.FindAll() in c:\dev\castle\svn\branches\1.0.x\ActiveRecord\Castle.ActiveRecord\Framework\ActiveRecordBase.Generic.cs:line 333 
     at CSharpFinal.InventoryMain.InventoryMain_Load(Object sender, EventArgs e) in C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\CSharpFinal\InventoryMain.cs:line 36 
     at System.Windows.Forms.Form.OnLoad(EventArgs e) 
     at System.Windows.Forms.Form.OnCreateControl() 
     at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible) 
     at System.Windows.Forms.Control.CreateControl() 
     at System.Windows.Forms.Control.WmShowWindow(Message& m) 
     at System.Windows.Forms.Control.WndProc(Message& m) 
     at System.Windows.Forms.ScrollableControl.WndProc(Message& m) 
     at System.Windows.Forms.ContainerControl.WndProc(Message& m) 
     at System.Windows.Forms.Form.WmShowWindow(Message& m) 
     at System.Windows.Forms.Form.WndProc(Message& m) 
     at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) 
     at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) 
     at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) 
     at System.Windows.Forms.SafeNativeMethods.ShowWindow(HandleRef hWnd, Int32 nCmdShow) 
     at System.Windows.Forms.Control.SetVisibleCore(Boolean value) 
     at System.Windows.Forms.Form.SetVisibleCore(Boolean value) 
     at System.Windows.Forms.Control.Show() 
     at CSharpFinal.Form1.inventoryToolStripMenuItem_Click(Object sender, EventArgs e) in C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\CSharpFinal\Form1.cs:line 51 
     at System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e) 
     at System.Windows.Forms.ToolStripMenuItem.OnClick(EventArgs e) 
     at System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e) 
     at System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e) 
     at System.Windows.Forms.ToolStripItem.FireEventInteractive(EventArgs e, ToolStripItemEventType met) 
     at System.Windows.Forms.ToolStripItem.FireEvent(EventArgs e, ToolStripItemEventType met) 
     at System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea) 
     at System.Windows.Forms.ToolStripDropDown.OnMouseUp(MouseEventArgs mea) 
     at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks) 
     at System.Windows.Forms.Control.WndProc(Message& m) 
     at System.Windows.Forms.ScrollableControl.WndProc(Message& m) 
     at System.Windows.Forms.ToolStrip.WndProc(Message& m) 
     at System.Windows.Forms.ToolStripDropDown.WndProc(Message& m) 
     at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) 
     at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) 
     at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) 
     at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg) 
     at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData) 
     at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context) 
     at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context) 
     at System.Windows.Forms.Application.Run(Form mainForm) 
     at CSharpFinal.Program.Main() in C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\CSharpFinal\Program.cs:line 17 
     at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args) 
     at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) 
     at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() 
     at System.Threading.ThreadHelper.ThreadStart_Context(Object state) 
     at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) 
     at System.Threading.ThreadHelper.ThreadStart() 


Castle.ActiveRecord.Framework.ActiveRecordException was unhandled 
    Message="Could not create the schema" 
    Source="Castle.ActiveRecord" 
    StackTrace: 
     at Castle.ActiveRecord.ActiveRecordStarter.CreateSchema() in c:\dev\castle\svn\branches\1.0.x\ActiveRecord\Castle.ActiveRecord\Framework\ActiveRecordStarter.cs:line 212 
     at CSharpFinal.Form1.reInitializeDatabaseToolStripMenuItem_Click(Object sender, EventArgs e) in C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\CSharpFinal\Form1.cs:line 65 
     at System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e) 
     at System.Windows.Forms.ToolStripMenuItem.OnClick(EventArgs e) 
     at System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e) 
     at System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e) 
     at System.Windows.Forms.ToolStripItem.FireEventInteractive(EventArgs e, ToolStripItemEventType met) 
     at System.Windows.Forms.ToolStripItem.FireEvent(EventArgs e, ToolStripItemEventType met) 
     at System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea) 
     at System.Windows.Forms.ToolStripDropDown.OnMouseUp(MouseEventArgs mea) 
     at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks) 
     at System.Windows.Forms.Control.WndProc(Message& m) 
     at System.Windows.Forms.ScrollableControl.WndProc(Message& m) 
     at System.Windows.Forms.ToolStrip.WndProc(Message& m) 
     at System.Windows.Forms.ToolStripDropDown.WndProc(Message& m) 
     at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) 
     at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) 
     at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) 
     at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg) 
     at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData) 
     at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context) 
     at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context) 
     at System.Windows.Forms.Application.Run(Form mainForm) 
     at CSharpFinal.Program.Main() in C:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\Projects\CSharpFinal\Program.cs:line 17 
     at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args) 
     at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) 
     at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() 
     at System.Threading.ThreadHelper.ThreadStart_Context(Object state) 
     at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) 
     at System.Threading.ThreadHelper.ThreadStart() 

InnerException.Message을 요청한 당신의 SQL Express를 연결 문자열이 사용자 인스턴스를 해제한다 becuase 아마 "An attempt to attach an auto-named database for file database.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share."

+0

전체 스택 추적을 게시하십시오. –

+0

같은 내부 예외 오류를 일으키는 두 개의 전체 스택 추적이 게시되었습니다. 나는 그들이 정말로 도움이된다고 생각하지 않는다. – epochwolf

답변

0

입니다. 사용자 인스턴스를 켠 상태로두면 필요한 경우 SQL이 데이터베이스를 연결하고 그렇지 않은 경우 SQL을 열어 데이터베이스를 연결합니다. 당신이 그것을 끄면 첨부는 permenant입니다. 데이터베이스가 이미 존재하므로 동일한 연결 문자열을 다시 사용하려고 시도하면 오류가 발생합니다.
해당 연결 문자열을 사용하여 데이터베이스를 연결하지 않았 으면 올바른 연결 문자열을 사용하기 전에 데이터베이스를 분리해야합니다. SQL Management Studio Express를 아직 다운로드하지 않은 경우 다운로드하십시오. 그러면 데이터베이스가 이미 연결되어 있고 쉽게 분리 할 수 ​​있습니다.

그래, 문제가되지 않는다면 SQL 서버가 데이터베이스 파일에 액세스 할 수 있습니까? 해당 폴더에 대한 사용 권한이 있습니까? 일반적으로 네트워크 서비스로 실행되므로 다른 사용자와 마찬가지로 파일에 대한 액세스 권한을 부여 할 수 있습니다. 모든 사용자에게 모든 권한을 부여하여 파일 사용 권한을 문제없이 제거 할 수 있습니다. 필요한 경우 사용 권한을 조정할 수 있습니다. SQL 서버 서비스 계정에 .mdf 파일에 대한 수정 권한이 필요하다고 생각합니다. 사용자 인스턴스 데이터베이스에 대한 .ldf 파일의 작성 위치를 알 수 없습니다. .mdf와 동일한 폴더에 파일 권한을 만들어야 할 수 있습니다.

+0

아무런 차이가 없었습니다. 같은 예외. 같은 스택 추적. 심지어 데이터베이스 파일의 절대 경로. – epochwolf

+0

이미 첨부되어 있습니다. 먼저 서버에 로그인하고 기존 데이터베이스의 연결을 해제해야합니다. 그런 다음 set user 인스턴스를 true로 제거하십시오. – pipTheGeek

+0

데이터베이스가 Management Studio에 연결되어 있지 않습니다. 사용자 인스턴스가 여전히 작동하지 않습니다. 재부팅을 시도했지만 여전히 작동하지 않습니다. – epochwolf

0

흠, 이것은 일종의 추측이지만 데이터베이스 이름을 지정해야합니까? (초기 문자열 conn)

+0

파일 데이터베이스 들어? – epochwolf

관련 문제