¾È±Ô °øºÎ¹æ

ACTIVE SERVER PAGE > Command - Attribute

µî·ÏÀÏ : 2017-07-04 17:05 Á¶È¸¼ö : 52,596

Command °³Ã¼ÀÇ ¼Ó¼º¿¡´Â ¾î¶²°ÍµéÀÌ ÀÖÀ»±î¿ä...
¿¹Á¦¸¦ º¸¸é¼­ Çϳª¾¿ ¼Ó¼ºÀ» ¾Ë¾Æº¸µµ·Ï ÇÏ°Ú½À´Ï´Ù.
 
  5.7.1 ActiveConnection ¼Ó¼º
 
AdcmdUnknown = 8
	adCmdText = 1
	AdcmdTable = 2
	adCmdStoredProc = 4
	adCmdFile = 100
	AdcmdTableDirect = 200

  	Set objCnn = Server.CreateObject("ADODB.Connection")
  	objCnn.Open ("Provider=SQLOLEDB;User ID=sa;Password=;Initial Catalog=test;Data Source=MOBBIE-ANKYU")
     
  	Set Cmd=Server.CreateObject("ADODB.Command")
  	set Cmd.ActiveConnection=objCnn
  	Cmd.CommandText="select * from board"
  	Cmd.CommandType=adcmdtext
  	set objCmd=Cmd.execute

  	do until objCmd.eof 
    		response.write objCmd("title")&"
"
    		objCmd.movenext
  	loop 
	
  	objCmd.close
  	objCnn.close



À§ÀÇ ¿¹Á¦´Â board Å×ÀÌºí¿¡¼­ ·¹Äڵ带 °¡Áö°í ¿À´Â ¿¹Á¦ ÀÔ´Ï´Ù.
¿©±â¿¡¼­´Â ActiveConnection ¼Ó¼º¸¸À» º¸°í ³Ñ¾î°¡µµ·Ï ÇÏ°Ú½À´Ï´Ù.
ActiveConnection ¼Ó¼ºÀº ÇöÀçÀÇ Command °³Ã¼°¡ ¼ÓÇØÀÖ´Â Connection °³Ã¼¸¦ ³ªÅ¸³À´Ï´Ù. À̼ӼºÀº
¿¬°áÀ» À§ÇÑ Á¤º¸¸¦ ¹®ÀÚ¿­·Î ÁöÁ¤Çϰųª, Connection °³Ã¼¸¦ ÁöÁ¤ÇÕ´Ï´Ù.

À§ÀÇ ¿¹Á¦¿¡¼­´Â objCnn Áï, Connection °³Ã¼¸¦ ÁöÁ¤Çß½À´Ï´Ù.

  5.7.2 CommandText ¼Ó¼º
 
  CommandText ¼Ó¼ºÀº Provider¸¦ ÅëÇؼ­ ½ÇÇàÇÒ ¸í·É¾î(sql¹®Àå,Å×À̺í¸í,ÀúÀåÇÁ·Î½ÃÁ®¸í)¸¦ ÁöÁ¤ÇÏ´Â ¼Ó¼ºÀÔ´Ï´Ù.
  ±âº»°ªÀº ±æÀÌ°¡ ¾ø´Â ¹®ÀÚ¿­ÀÔ´Ï´Ù.
 
  5.7.1 ¿¹Á¦¿¡¼­´Â "select * from board"¿Í °°ÀÌ sql¹®ÀåÀ» ÀÔ·ÂÇØ ³Ö¾ú½À´Ï´Ù.
 
  ¸¸¾à ÀúÀå ÇÁ·Î½ÃÁ®¸¦ »ç¿ëÇÏ°í ½ÍÀ¸¸é ÇÁ·Î½ÃÁ® À̸§À» ³ÖÀ¸½Ã¸é µË´Ï´Ù.
 


	<%
  	Set objCnn = Server.CreateObject("ADODB.Connection")
  	Set Cmd=Server.CreateObject("ADODB.Command")
  	Set objPara=Server.CreateObject("ADODB.parameter")

  	objCnn.Open ("Provider=SQLOLEDB;User ID=sa;Password=;Initial Catalog=pubs;Data Source=MOBBIE-ANKYU")
     
  	set Cmd.ActiveConnection=objCnn
  	Cmd.CommandText="byroyalty"
  	Cmd.CommandType=adcmdStoredProc
  	Cmd.CommandTimeout=15
  
  	objPara.type=adInteger
  	objPara.size=3
  	objPara.direction=adParamInput
  	objPara.value=100
  	cmd.parameters.append objPara
  	set objCmd=Cmd.execute

  	do until objCmd.eof 
    		response.write objCmd(0)&"
"
    		objCmd.movenext
  	loop 
	
  	objCmd.close
  	objCnn.close
  	%>




À§ÀÇ ¿¹Á¦´Â pubs µ¥ÀÌŸº£À̽º¿¡ ÀÖ´Â byroyalty ¶ó´Â ÇÁ·Î½ÃÁ®¸¦ »ç¿ëÇÑ ¿¹ ÀÔ´Ï´Ù.

À§ÀÇ ¿¹Á¦¿¡¼­´Â commandText ¿¡ ÇÁ·Î½ÃÁ® À̸§À» ³Ö¾î¼­ ÀÌ ÇÁ·Î½ÃÁ®¸¦ »ç¿ëÇÑ ¿¹ÀÔ´Ï´Ù. ÀÌ ÇÁ·Î½ÃÁ®´Â
ÆĶó¸ÞŸÀÇ °ªÀÌ ÇÊ¿äÇϹǷΠ, parameter ÀνºÅϽº¸¦ »ý¼ºÇؼ­ parameter Ä÷º¼ÇÀ» »ç¿ëÇß½À´Ï´Ù.
¿©±â¿¡¼­´Â parameter°¡ Áß¿äÇÑ°Ô ¾Æ´Ï±â ¶§¹®¿¡, ÀÌÂëÇؼ­ ³Ñ¾î°¡±¸¿ä, parameter´Â ³ªÁß¿¡ ´Ù½Ã ÀÚ¼¼È÷
¾Ë¾Æº¸µµ·Ï ÇÏ°Ú½À´Ï´Ù.

  5.7.3 CommandTimeout ¼Ó¼º
 
  À§ÀÇ ¿¹Á¦¸¦ º¸½Ã¸é CommandTimeOut ¼Ó¼ºÀÌ ÀÖ½À´Ï´Ù. ÀÌ ¼Ó¼ºÀº ¸í·É¾î°¡ °á°ú¸¦ ¹ÝȯÇÒ ¶§±îÁö¸¦ ´ë±âÇÏ´Â
  ½Ã°£À» ³ªÅ¸³À´Ï´Ù. ±âº»°ªÀº 30ÃÊ·Î µÇ¾ú½À´Ï´Ù.
 
  ¸¸¾à ÀÌ ½Ã°£À» 0À¸·Î ÁöÁ¤ÇÏ°Ô µÇ¸é ¹«ÇÑ´ë·Î °á°ú¸¦ ±â´Ù¸®°Ô µË´Ï´Ù.
  Connection °³Ã¼¿¡µµ CommandTimeout ¼Ó¼ºÀÌ ÀÖÁö¸¸, Command °³Ã¼ÀÇ ÀÌ ¼Ó¼º°ú´Â ¾Æ¹«·± °ü°è°¡ ¾ø½À´Ï´Ù.
 
  5.7.4 CommandType ¼Ó¼º
 
  CommandType ¼Ó¼ºÀº Command °³Ã¼ÀÇ Çü½ÄÀ» ³ªÅ¸³À´Ï´Ù.
 
  Áï, CommandTextÀÇ ¹®ÀÚ¿­ÀÌ SQL¹®Àå,ÇÁ·Î½ÃÁ®, Å×À̺í¸í, ÀÎÁö¸¦ °áÁ¤ÇÏ°Ô µË´Ï´Ù.
 
À§ÀÇ ¿¹Á¦¿¡¼­ adcmdStoredProc¸¦ ÁöÁ¤Ç߱⶧¹®¿¡ ÇÁ·Î½ÃÁ®·Î ÁöÁ¤µÈ°ÍÀ̸ç, óÀ½ ¿¹Á¦Ã³·³ adcmdtext·Î ÁöÁ¤µÇ¾úÀ¸´Ï,
¸í·É¾î³ª ¶Ç´Â ÇÁ·Î½ÃÁ®·Î ÀνÄÀÌ µÇ´Â °ÍÀÔ´Ï´Ù.

CommandType ÀÇ »ó¼ö°ªÀº 6°¡Áö°¡ ÀÖ½À´Ï´Ù ¾Æ·¡ Ç¥¸¦ º¸½Ã¸é ½±°Ô ÀÌÇØ°¡ °¡½Ç°Í °°³×¿ä.
 
CommandType ¼Ó¼ºÀÇ °³Ã¼Çü½Ä
»ó¼ö °ª ¼³ ¸í
adCmdUnknown
adCmdText
adCmdTable
adCmdStoredProc
adCmdFile
adCmdTableDirect
8
1
2
4
256
512
µðÆúÆ®°ª, Command °³Ã¼ÀÇ Å¸ÀÔÀ» ¾Ë¼ö ¾øÀ½À¸·Î ÁöÁ¤
¸í·É¾î ¶Ç´Â ÀúÀå ÇÁ·Î½ÃÁ®¸¦ ÅؽºÆ®·Î ÁöÁ¤ÇÔ.
Å×À̺íÀ» ÁöÁ¤ÇÑ´Ù.(³»ºÎÀûÀÎ sql¹®Àå¿¡ ÀÇÇØ Çʵ尡 »ý¼ºµÊ)
ÀúÀåÇÁ·Î½ÃÁ®¸¦ ÁöÁ¤ÇÑ´Ù.
Persisted Recordset °³Ã¼ÀÇ ÆÄÀϸí ÁöÁ¤.
Å×À̺íÀ» ÁöÁ¤(¸ðµç Çʵå)
  

  5.7.5 Properties ¼Ó¼º
 


	<%
  	Set objCnn = Server.CreateObject("ADODB.Connection")
	Set Cmd=Server.CreateObject("ADODB.Command")
	Set objPara=Server.CreateObject("ADODB.parameter")

	objCnn.Open ("Provider=SQLOLEDB;User ID=sa;Password=;Initial Catalog=pubs;Data Source=MOBBIE-ANKYU")

	strCmd="select * from board"
	cmd.activeConnection=objCnn
	cmd.commandtext=strCmd
       
	for i=0 to Cmd.properties.count-1
		response.write cmd.properties(i).name&":"&cmd.properties(i).value&"
"
	next   
	
	objCnn.close
	%>


À§ÀÇ ¿¹Á¦¸¦ ÇÔ ½ÇÇàÇØ º¸¼¼¿ä.
Command °³Ã¼ÀÇ peoperties °ªµéÀÌ ¾î¶²°ÍµéÀÌ ÀÖ´ÂÁö È®ÀÎÇϽǼö ÀÖ½À´Ï´Ù.

Command °³Ã¼ÀÇ ¼Ó¼ºÀº À§ÀÇ ¼Ó¼ºµé ¸»°íµµ ¿©·¯°¡Áö°¡ ÀÖÁö¸¸, ´õ ÀÚ¼¼ÇÑ ³»¿ëÀº Àü¹®¼­ÀûÀ» Âü°íÇϽñ⠹ٶø´Ï´Ù.
 
±×·³, ´ÙÀ½¿¡´Â ¸Þ¼­µåµé¿¡ ´ëÇؼ­ »ìÆ캸µµ·Ï ÇÏ°Ú½À´Ï´Ù.
 
¡Ø Ȥ½Ã µµ¿òÀÌ µÇ¼Ì´Ù¸é ´ñ±Û¿¡ ÇѸ¶µð ³²°ÜÁÖ¼¼¿ä!
ÀÛ¼ºÀÚ   ºñ¹Ð¹øÈ£
ÀÚµ¿±Û ¹æÁö     (ÀÚµ¿±Û ¹æÁö ±â´ÉÀÔ´Ï´Ù.)
³»¿ë   ´ñ±Û´Þ±â 
À̸ÞÀÏ ¹®ÀÇ : cak0280@nate.com  
Copyright 2000 By ENTERSOFT.KR All Rights Reserved.