성태의 닷넷 이야기
홈 주인
모아 놓은 자료
프로그래밍
질문/답변
사용자 관리
사용자
메뉴
아티클
외부 아티클
유용한 코드
온라인 기능
MathJax 입력기
최근 덧글
[정성태] Get Started with Milvus Vector DB i...
[정성태] cyberark/PipeViewer - A tool that...
[정성태] WinForms in a 64-Bit world – our st...
[정성태] 예제에서 SELECT_SQL도 내부적으로는 SqlCommand/...
[victor] SELECT_LINQ SELECT_SQL 같은 쿼리인...
[victor] 답변 갑사합니다. 예외(Exception)가 났습니다. ...
[정성태] 일단, 위의 방식대로 하면 예외(Exception) 없이 잘 동...
[정성태] Windows 10 (버전 1809)에 이런 기능이 ^^ 추가되...
[정성태] pde windbg extension ; https://lea...
[정성태] // GetEnumerator extensions for Ran...
글쓰기
제목
이름
암호
전자우편
HTML
홈페이지
유형
제니퍼 .NET
닷넷
COM 개체 관련
스크립트
VC++
VS.NET IDE
Windows
Team Foundation Server
디버깅 기술
오류 유형
개발 환경 구성
웹
기타
Linux
Java
DDK
Math
Phone
Graphics
사물인터넷
부모글 보이기/감추기
내용
<div style='display: inline'> <h1 style='font-family: Malgun Gothic, Consolas; font-size: 20pt; color: #006699; text-align: center; font-weight: bold'>UWP 앱에서 SQL Server 데이터베이스 연결 방법</h1> <p> 다음의 글에도 나오지만,<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > UWP 앱에서 SQL Server 데이터베이스 사용 ; <a target='tab' href='https://learn.microsoft.com/ko-kr/windows/uwp/data-access/sql-server-databases'>https://learn.microsoft.com/ko-kr/windows/uwp/data-access/sql-server-databases</a> </pre> <br /> SQL 서버로의 연결 문자열은 윈도우 통합 인증과, SQL 서버 자체의 인증 방식에 따라 다음과 같이 2가지 유형을 지정할 수 있습니다.<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > // 1) Connection string for using <span style='color: blue; font-weight: bold'>Windows Authentication</span>. private string connectionString = @"Data Source=YourServerName\SQLEXPRESS;Initial Catalog=NORTHWIND;Integrated Security=SSPI"; // 2) This is an example connection string for using <span style='color: blue; font-weight: bold'>SQL Server Authentication</span>. // private string connectionString = // @"Data Source=YourServerName\YourInstanceName;Initial Catalog=DatabaseName; User Id=XXXXX; Password=XXXXX"; </pre> <br /> 샌드 박스 환경에서 실행되는 UWP 앱은 기본적으로 "윈도우 통합 인증"을 위한 권한이 없기 때문에 SQL 서버 인증을 사용해야 합니다. 그렇지 않고 통합 인증 연결 문자열을 사용하게 되면 다음과 같은 식의 예외가 발생합니다.<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > System.Data.SqlClient.SqlException: Failed to generate <a target='tab' href='https://devblogs.microsoft.com/oldnewthing/20231109-00/?p=108988'>SSPI context</a>. ErrorCode=NoCredentials at System.Data.SqlClient.SNI.SNIProxy.GenSspiClientContext(SspiClientContextStatus sspiClientContextStatus, Byte[] receivedBuff, Byte[]& sendBuff, Byte[] serverName) at System.Data.SqlClient.SNI.TdsParserStateObjectManaged.GenerateSspiClientContext(Byte[] receivedBuff, UInt32 receivedLength, Byte[]& sendBuff, UInt32& sendLength, Byte[] _sniSpnBuffer) at System.Data.SqlClient.TdsParser.SNISSPIData(Byte[] </pre> <br /> 그렇긴 한데, 원한다면 통합 인증을 사용할 수 있는 방법이 있습니다.<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > Can't connect to database running on SQL Server on host from UWP ; <a target='tab' href='https://github.com/dotnet/corefx/issues/22890'>https://github.com/dotnet/corefx/issues/22890</a> </pre> <br /> 위의 덧글에 따라 Package.appxmanifest 파일에서 "Enterprise Authentication" 항목을 활성화시키면 됩니다.<br /> <br /> <img alt='uwp_db_connection_1.png' src='/SysWebRes/bbs/uwp_db_connection_1.png' /><br /> <br /> 이 옵션은 윈도우에 로그인한 사용자의 권한을 UWP 앱에서도 사용할 수 있도록 하므로 SQL 서버로의 통합 인증을 가능하게 만듭니다.<br /> </p><br /> <br /><hr /><span style='color: Maroon'>[이 글에 대해서 여러분들과 의견을 공유하고 싶습니다. 틀리거나 미흡한 부분 또는 의문 사항이 있으시면 언제든 댓글 남겨주십시오.]</span> </div>
첨부파일
스팸 방지용 인증 번호
1289
(왼쪽의 숫자를 입력해야 합니다.)