■ SQL Server 연결을 구하는 방법을 보여준다. (윈도우즈 인증)
▶ SQL Server 연결 구하기 (윈도우즈 인증) 예제 (VB)
1 2 3 4 5 |
Dim pConnection As ADODB.Connection Set pConnection = GetSQLServerConnectionWithWindowsAuthentication("127.0.0.1", "testdb") |
▶ SQL Server 연결 구하기 (윈도우즈 인증) (VB)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
Public Function GetSQLServerConnectionWithWindowsAuthentication(strDataSource As String, strInitialCatalog As String) As ADODB.Connection Dim pConnection As ADODB.Connection Dim strConnectionString As String Set GetSQLServerConnectionWithWindowsAuthentication = Nothing On Error GoTo ErrorLabel Set pConnection = New ADODB.Connection strConnectionString = "Provider=SQLOLEDB.1;Data Source=" + strDataSource + ";Initial Catalog=" + strInitialCatalog + ";Integrated Security=SSPI;Persist Security Info=False" pConnection.Open strConnectionString On Error GoTo 0 Set GetSQLServerConnectionWithWindowsAuthentication = pConnection Exit Function ErrorLabel: End Function |