<!--#include virtual="/include/lib/dbcon.asp"-->
<!--#include virtual="/include/function/default_func.asp"-->
<%

table			= "view_address_member"		'테이블
idx_field		= "adr_idx"			'기본키
oreder_filed	= "adr_name asc, adr_idx asc"	'정렬기준 필드
Query_Fields	= "adr_idx, bdm_idx, adr_m_id, adr_name, adr_mobile1, adr_mobile2, adr_mobile3, adr_c_memo, bdm_menuname" '불러올 필드

'==================조합 쿼리문=======================

Query_Where = " where adr_m_id = '" & session("ss_m_id") & "'"
Query_OrderBy = " ORDER BY " & oreder_filed
'==================조합 쿼리문=======================

'========================리스트 출력 쿼리문 생성======================
'MS-SQL
sql = "select " & Query_Fields & " from " & table & Query_Where & Query_OrderBy
'========================리스트 출력 쿼리문 생성 끝======================
'response.write sql


Set rs = Dbcon.Execute( sql )
If rs.bof Or rs.eof Then
	List_data = Null
	TotalCnt = 0
else
	List_data = rs.getrows
	TotalCnt = recordcount
End if



If IsNull(list_data) Then
	Back_back("생성할 주소록이 없습니다.")
Else
	Response.ContentType = "application/vnd.ms-excel"
	Response.AddHeader "Content-Disposition","attachment;filename=sheet1.xls"
End If

Response.write "이름	핸드폰번호	그룹	메모" & vbcrlf

For i = 0 To UBound(list_data, 2)
	Call arr2Value(Query_Fields, "list_data", i )
	Response.write adr_name & "	"
	Response.write adr_mobile1 & "-" & adr_mobile2 & "-" & adr_mobile3 & "	"
	Response.write bdm_menuname & "	"
	Response.write adr_c_memo & vbcrlf
Next

dbcon.close()
Set dbcon = Nothing
Response.End


Function arr2Value(R_Fields, arrObj, recordcount)

	Dim i, R_Fields_arr
	R_Fields = Replace(R_Fields, " ", "")
	R_Fields_arr = Split(R_Fields, ",")
	
	For i = 0 To UBound(R_Fields_arr)

		execute(R_Fields_arr(i)&" = "&arrObj&"("&i&","&recordcount&")")
		'response.write R_Fields_arr(i)&" = "&eval(arrObj&"("&i&","&recordcount&")")&"<br>"

	next

End Function
%>