2012-09-22 1 views
0

저는 C#에서 Windows 양식 응용 프로그램을 개발했습니다. 저는이 Microsoft Visual Studio 2010에 사용했습니다. 이제 설치 패키지 (또는 사람들에게 내 프로그램을 제공 할 수있게 해주는 프로그램)를 생성하고 싶지만 이상한 문제가 발생했습니다.설치 패키지를 만든 후 프로그램이 데이터베이스를 보지 못합니다.

디버그 모드를 사용할 때 모든 것이 정상적으로 작동하므로 MyDocuments \ Visual 2010 \ 솔루션 이름 \ 프로젝트 이름 \ bin \ Debug에서 컴파일 된 프로그램을 가져 와서 테스트 해 보겠습니다. 에이 오류 실행하고 포기하지 않는 그녀의 컴퓨터 프로그램 :

System.Data.SqlClient.SqlException: An error has occurred with the onset of the network or connect to a SQL Server server. Can not find server or it is not available. Verify that the instance name is correct and that the configuration of SQL Server allow remote connections. (Provider: SQL Network Interfaces, error: 26 - Error locating a specific server/instance) 
    in System.Data.ProviderBase.DbConnectionPool.GetConnection (DbConnection owningObject) 
    in System.Data.ProviderBase.DbConnectionFactory.GetConnection (DbConnection owningConnection) 
    in System.Data.ProviderBase.DbConnectionClosed.OpenConnection (DbConnection outerConnection, DbConnectionFactory connectionFactory) 
    in System.Data.SqlClient.SqlConnection.Open() 
    in System.Data.Common.DbDataAdapter.QuietOpen (IDbConnection connection, ConnectionState & originalState) 
    in System.Data.Common.DbDataAdapter.FillInternal (DataSet dataset, DataTable [] DataTables, Int32 startRecord, Int32 MaxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) 
    at System.Data.Common.DbDataAdapter.Fill (DataTable [] DataTables, Int32 startRecord, Int32 MaxRecords, IDbCommand command, CommandBehavior behavior) 
    at System.Data.Common.DbDataAdapter.Fill (DataTable dataTable) 
    in Home_Video_Catalog.HVCDBDataSetFilmsTableAdapters.FilmsTableAdapter.Fill (FilmsDataTable dataTable) in C: \ Documents and Settings \ Aru \ My Documents \ Visual Studio 2010 \ Projects \ Home Video Catalog \ Home Video Catalog \ HVCDBDataSetFilms.Designer.cs: line 868 
    in Home_Video_Catalog.MainWindow.MainWindow_Load (Object sender, EventArgs e) in C: \ Documents and Settings \ Aru \ My Documents \ Visual Studio 2010 \ Projects \ Home Video Catalog \ Home Video Catalog \ MainWindow.cs: line 27 
    in System.Windows.Forms.Form.OnLoad (EventArgs e) 
    in DevComponents.DotNetBar.Office2007RibbonForm.OnLoad (EventArgs e) 
    in System.Windows.Forms.Form.OnCreateControl() 
    at System.Windows.Forms.Control.CreateControl (Boolean fIgnoreVisible) 
    at System.Windows.Forms.Control.CreateControl() 
    in System.Windows.Forms.Control.WmShowWindow (Message & m) 
    at System.Windows.Forms.Control.WndProc (Message & m) 
    in System.Windows.Forms.ScrollableControl.WndProc (Message & m) 
    in System.Windows.Forms.ContainerControl.WndProc (Message & m) 
    in System.Windows.Forms.Form.WmShowWindow (Message & m) 
    in System.Windows.Forms.Form.WndProc (Message & m) 
    in DevComponents.DotNetBar.Office2007RibbonForm.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.Callback (IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) 

을 ... 그래서 내가 설치 프로젝트를 만들고 내 프로젝트에 대한 설정을 작성하는 경우 어쩌면 경우가 확인 될 것이라고 생각했습니다 ...하지만 오류는 이전 오류 코드와 동일합니다.

내가 아주 (의 app.config 및 프로젝트에서 속성 \ settings.settings)가 적절한 연결 문자열 프로젝트에 내 config 파일에서 렸기 때문에, 그것을 얻을하지 않습니다는 :

connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\HVCDB.mdf;Integrated Security=True;User Instance=True" 

또한 재미있는 것은 그 경로입니다 오류 메시지가 컴퓨터에 유효하다 (이것은 어디했습니다 프로젝트)

=. \ 연결 문자열에 SQLEXPRESS 설치 SQLSERVER 익스프레스의 인스턴스를 참조 나 :

답변

0

구문 데이터 소스를 도와주세요 로컬 컴퓨터에서.
오류 메시지에서 대상 설치 컴퓨터에 SqlServer Express가 설치되어 있지 않은 것으로 가정합니다.
그래서 두 가지 옵션이 있습니다 :

  • 대상 설치 기계
  • 변경에 작업 기계를 참조 데이터베이스 카탈로그가 발견 사용하도록 연결 문자열을 SQL Server Express를 설치합니다. 물론

    Data Source=YOURMACHINENAME\SQLEXPRESS;Initial Catalog=YOURDATABASENAME;..... 
    

, 다른 하나에서 개발 컴퓨터에 연결이 사용자 보안을 구성, 원격 연결은 SQL Server를 구성, 방화벽 포트를 열어야합니다 .....

Remote connections
Firewall

응용 프로그램이 실행되는 모든 컴퓨터에서 SQL Server를 설치하는 경로로 이동하지 않으려면 01과 같은 다른 데이터베이스를 조사 할 수 있습니다, Sql Compact Edition 또는 비공유 버전의 SqlServer LocalDB

관련 문제