"엑셀 DB연결"의 두 판 사이의 차이
DB CAFE
(새 문서: '엑셀 DB 접속 '(중요) 환경설정>> 매크로편집화면 >도구 >참조 - Microsoft Active Data Object 2.8 Library 체크 <source lang='javascript'> '변수를 명시적...) |
|||
1번째 줄: | 1번째 줄: | ||
− | '엑셀 DB 접속 | + | ''''엑셀 DB 접속 |
− | '(중요) 환경설정>> 매크로편집화면 >도구 >참조 - Microsoft Active Data Object 2.8 Library 체크 | + | '(중요) 환경설정>> 매크로편집화면 >도구 >참조 - Microsoft Active Data Object 2.8 Library 체크''' |
+ | |||
<source lang='javascript'> | <source lang='javascript'> | ||
'변수를 명시적으로 선언 함 | '변수를 명시적으로 선언 함 |
2019년 1월 23일 (수) 16:05 판
thumb_up 추천메뉴 바로가기
- DBA { Oracle DBA 명령어 > DBA 초급 과정 > DBA 고급 과정 }
- 튜닝 { 오라클 튜닝 목록 }
- 모델링 { 데이터 모델링 가이드 }
'엑셀 DB 접속 '(중요) 환경설정>> 매크로편집화면 >도구 >참조 - Microsoft Active Data Object 2.8 Library 체크
'변수를 명시적으로 선언 함
Option Explicit
'DB접속 문자열
Const DB_CONNECTION = "Provider=OraOLEDB.Oracle;Data Source=RTIS_DEV;User Id = xxx; Password=xxxx;"
Sub table_info_query()
'Record Set
Dim rs As New ADODB.Recordset
'Sql Query
Dim strSQL As String
'접속문자열
Dim strConn As String
Dim i As Integer
'DB연결
strConn = DB_CONNECTION
strSQL = "SELECT * FROM TAB"
'RecordSet 처리
rs.Open strSQL,strConn
If rs.EOF Then
MsgBox "조회조건에 해당하는 자료가 없습니다."
Else
'타이틀 만 표시
For i = 1 To rs.Fields.Count
Cells(1,i).Value = rs.Field(i-1).Name
Next
'데이터 Fetch
With ActiveSheet
.Range("A2").CopyFromRecordset rs
End With
End If
rs.Close
Set rs = Nothing
End Sub