db_connect oledb 디비접속

<%
‘//////////////////// DB접속정보  DBconn.asp //////////////////////////////////
dim db
dim db_connect
dim db_name
dim db_ip
dim db_id
dim db_pass

db_connect=”oledb”
db_ip=”111.111.111.111,1111″
db_name=”DBX”
db_id=”IDX”
db_pass=”PASSX”

sub dbconn_sub
dim strConnection
set db = Server.CreateObject(“ADODB.Connection”)
strConnection = “Provider=SQLOLEDB;SERVER=”& db_ip &”;Uid=”& db_id &”;Pwd=”& db_pass &”;Database=”& db_name &”;network library=dbmssocn”
db.open strConnection
end sub
%>

<%   ‘사용
Option Explicit
‘On Error Resume Next
Dim strSql,Rs

call dbconn_sub

strSQL =”Select top 10 * from DBX”

SET Rs=db.Execute(strSQL)

if Not(Rs.BOF or Rs.EOF) then
Do until Rs.EOF
response.write   Rs(“C001”)  ‘컬럼테스트
Rs.moveNext
Loop
end if

Rs.close:Set Rs=nothing
‘// DB접속끊기
db.close : set db=nothing

%>