2012-05-22 1 views
0
  1. 라이브러리 설정
  2. 나는 둘 다 제대로

    나는 데이터베이스에 액세스 라이브러리 프로젝트의 app.config에서 설정 한

    작업하는

의 Web.config에 구성된 데이터베이스에 액세스하는 웹 프로젝트가

이제 웹 프로젝트의 라이브러리를 사용하고 싶습니다. Visual Studio에서 잘 작동합니다. 프로덕션 서버에서 웹 프로젝트는 데이터베이스에 액세스하지만 라이브러리는 프로젝트 웹에서 데이터베이스에 액세스 할 수 없습니다.

app.config와 web.config의 ConnectionString은 동일합니다. 프로덕션 서버에서 web.config 설정을 사용하지 않아야합니까? 내 영어

에 대한

감사하고 죄송

편집

의 web.config 및 app.config에 connectionStrings

<connectionStrings> 
    <add name="IntranetConnectionString" 
     connectionString="Data Source=(local)\SQLExpress;Initial Catalog=Intranet;Integrated Security=True;" 
     providerName="System.Data.SqlClient" /> 
    <add name="Database.Properties.Settings.IntranetConnectionString" 
     connectionString="Data Source=(local)\SQLEXPRESS;Initial Catalog=Intranet;Integrated Security=True" 
     providerName="System.Data.SqlClient" /> 
</connectionStrings> 

오류 :

A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)

+0

당신이 얻는 오류는 무엇입니까? stacktrace를 보여줄 수 있습니까? – Jorge

답변

0

만약 내가 제대로 이해하고, 지역을 복사 해보십시오. 라이브러리에서이 작업을 수행하려면 right-click 프로젝트에서 참조를 입력 한 다음 속성에서 TrueCopy Local으로 설정하면 서버에 라이브러리가 로컬로 배치됩니다. 그것은 web.config/app.config 문제가 있다면

문제가 라이브러리의 참조와 관련된 경우이 작동합니다, 그것은 도움이되지 않습니다

+0

문제는 참조가 아니며 구성입니다. --- 스페인어 : 이 문제는 구성 할 수 없습니다. – Leonardo

+0

.config 파일을 게시 할 수 있습니까? – Luis

+0

.... <이름 추가> "IntranetConnectionString"connectionString = "데이터 원본 = (로컬) \ SQLExpress; 초기 카탈로그 = 인트라넷; 통합 보안 = True; providerName = "System.Data.SqlClient"/> ..... – Leonardo

0

DLL이 일반적으로 그것을 호출하는 호스트 응용 프로그램의 app.config에 소요 자체 구성이 아닙니다. 여기에 고기가 있니?

+0

이것은 내가 생각하지만 작동하지 않습니다 ... – Leonardo

+0

당신이 그것을 게시하면 구성은 app.config가 아니라 [app_name] .exe.config로 간다. 무엇이 잘못 되었나요? – edocetirwi

+0

웹 프로젝트 (exe가 아님)입니다. 내가 web.config를 게시하면 올바른 것입니다. 데이터베이스 액세스는 응용 프로그램 내에서 가능하지만 DLL에서는 작동하지 않습니다 .DLL은 web.config 설정을 사용하지 않습니다! ! – Leonardo

0

솔루션 : taBLL에서

String cs = System.Configuration.ConfigurationManager.ConnectionStrings["IntranetConnectionString"].ToString(); 
TestBLL taBLL = new TestBLL(cs); 

가 있습니다

는 DLL에서 웹 프로젝트에서 ConnectionString을

public TestBLL(String ConnectionString) 
{ 
    TestTableAdapter ta = new TestTableAdapter(); 
    ta.Connection = new System.Data.SqlClient.SqlConnection(ConnectionString); 
} 

를받는 생성자 DataTable에 액세스 할 수 클래스를 생성 각각의 쿼리에 접근하는 방법

관련 문제