µ¥ÀÌÅͺ£À̽º¿ÍÀÇ ¿¬µ¿ - Delphi
Á¶È¸ : 971 À̸§ : ¾Æ¹«³ª
E-mail :
(3) µ¥ÀÌÅͺ£À̽º¿ÍÀÇ ¿¬µ¿ - Delphi Á¶È¸(528)

ISAPI/MTS °øÅë | 2004/09/20 (¿ù) 17:59 ÃßõÇϱâ(0) | ½ºÅ©·¦Çϱâ(1)



Delphi¸¦ »ç¿ëÇÏ¿© Ŭ¶óÀ̾ðÆ®/¼­¹ö ÇÁ·Î±×·¡¹ÖÀ» Çغ¸½Å ºÐÀ̶ó¸é BDE(Borland Database Engine)¿¡ Àͼ÷ÇÏ½Ç °Ì´Ï´Ù. À¥¼­¹ö ÇÁ·Î±×·¡¹Ö¿¡¼­µµ µ¿ÀÏÇÑ ¹æ½ÄÀ¸·Î µ¥ÀÌÅͺ£À̽º¿Í ¿¬µ¿ÇÒ ¼ö ÀÖ½À´Ï´Ù. Áï ISAPI Extension¿¡¼­´Â WebModule À§¿¡, MTS COM component¿¡¼­´Â MTS DataModule À§¿¡ µ¥ÀÌÅͺ£À̽º°ü·Ã ÄÄÆ÷³ÍÆ®¸¦ ¿Ã·Á³õ°í ¾²¸é µÇ´Â °ÍÀÌÁÒ.
Á¦°¡ »ç¿ëÇÏ°í ÀÖ´Â Delphi´Â 4.0 + SP3 ¹öÁ¯Àε¥, ºÒÇàÇÏ°Ôµµ BDE°¡ ¸ÖƼ¾²·¹µå¸¦ ¿Ïº®ÇÏ°Ô Áö¿øÇÏÁö ¸øÇϱ⠶§¹®¿¡ request°¡ ¸ô¸®¸é ¸ðµâÀÌ ´Ù¿îµÇ´Â »çÅ°¡ ¹ß»ýÇÕ´Ï´Ù. ISAPI ExtensionÀ̶ó¸é À¥¼­¹ö°¡ Åë°·Î ´Ù¿îµÇ´Â »çÅ°¡ ¹ß»ýÇÏÁö¿ä.. Áö±Ý ³ª¿Í ÀÖ´Â 5.0 ¹öÁ¯¿¡¼­´Â ÀÌ°ÍÀÌ ÇØ°áµÇ¾ú´ÂÁö ¸ð¸£°Ú½À´Ï´Ù. ³ªÁß¿¡ ½áº¸°í ¾Ë·Áµå¸®ÁÒ.
DelphiÀÇ µ¥ÀÌÅͺ£À̽º °ü·Ã ÄÄÆ÷³ÍÆ®´Â ¸·°­ÇÑ Æí¸®ÇÔÀ» Á¦°øÇϴµ¥ ÀÌ°É Æ÷±âÇØ¾ß µÈ´Ù´Ï Àúµµ °¡½¿ÀÌ ¾ÆÇÁ±º¿ä.. --;
Delphi·Î µ¥ÀÌÅͺ£À̽º¿Í ¿¬µ¿ÇÏ´Â ¹æ¹ýÀº ¿©·¯°¡Áö°¡ ÀÖ½À´Ï´Ù. ¾Õ¼­ ¸»¾¸µå¸° BDE¿Ü¿¡µµ ADO, OLEDB, ODBC°¡ ±× ´ëÇ¥ÀûÀÎ ¿¹ÀÌÁö¿ä. Delphi 5.0 ¹öÁ¯¿¡´Â ADO ÄÄÆ÷³ÍÆ®°¡ »õ·Î Ãß°¡µÇ¾ú´õ±º¿ä. Àú´Â ±× ÄÄÆ÷³ÍÆ®´Â ¸ø½áºÃ°í ¼Ò½º³»¿¡¼­ ADO °´Ã¼¸¦ »ý¼ºÇÏ¿© »ç¿ëÇغýÀ´Ï´Ù. BDE¸¦ Á¦¿ÜÇÏ°í ¼Óµµ¸¦ ºñ±³Çغ¸ÀÚ¸é ODBC°¡ °¡Àå ºü¸£°í ±× ´ÙÀ½ÀÌ OLEDB, ±×¸®°í ADOÀÇ ¼øÀÔ´Ï´Ù. ¼Óµµ°¡ ºü¸£´Ù´Â °ÍÀº °°Àº ½Ã°£³»¿¡ ¸¹Àº ¼öÀÇ request¸¦ ó¸®ÇÒ ¼ö ÀÖ´Ù´Â °ÍÀ» ÀǹÌÇϸç, ½ÇÁ¦·Î ä³Î¾ÆÀÌ °Ô½ÃÆÇ/ÀÚ·á½Ç ¸ðµâÀº ODBC¸¦ »ç¿ëÇÏ¿© ±¸ÇöÇÏ¿´½À´Ï´Ù.
º» ¹®¼­¿¡¼­´Â ADO¿Í ODBC¸¦ »ç¿ëÇÏ´Â ¹æ¹ýÀ» ¼Ò°³Çص帳´Ï´Ù. ADO´Â ADO °´Ã¼¸¦ »ý¼ºÇÏ¿© »ç¿ëÇÏ´Â ¹æ¹ýÀ» ¿¹Á¦¸¦ ÅëÇÏ¿© º¸¿©µå¸± °ÍÀÌ°í, ODBC´Â ODBC API·Î ¸¸µé¾îÁø Ä¿½ºÅÒ ÄÄÆ÷³ÍÆ®¸¦ »ç¿ëÇÏ°Ú½À´Ï´Ù.
¾Æ·¡ÀÇ ³»¿ëÀº ISAPI Extension°ú MTS COM¿¡ °øÅëÀûÀ¸·Î Àû¿ëÇÒ ¼ö ÀÖ½À´Ï´Ù. SQLServer 6.5 RDBMS¸¦ »ç¿ëÇÏ´Â ISAPI ExtensionÀ» ¿¹Á¦·Î º¸¿©µå¸®°Ú½À´Ï´Ù.
ADO °´Ã¼ÀÇ »ç¿ë
ADO °´Ã¼¸¦ »ç¿ëÇϱâ À§Çؼ­ ADOÀÇ Type Library ÆÄÀÏÀÌ ÇÊ¿äÇÕ´Ï´Ù. WindowsNT¿¡ MDAC(Microsoft Data Access Component)¸¦ ¼³Ä¡ÇÏ°Ô µÇ¸é ÃֽŠ¹öÁ¯ÀÇ ADO¸¦ »ç¿ëÇÒ ¼ö ÀÖ½À´Ï´Ù. MDACÀº Microsoft¿¡¼­ ¹«·á·Î ¹èÆ÷ÇÕ´Ï´Ù.
Delphi¿¡¼­ ADOÀÇ Type Library¸¦ ¾ò¾î¿À´Â ¹æ¹ýÀº ´Ù¸¥ COM °´Ã¼¿¡¼­ÀÇ ±×°Í°ú µ¿ÀÏÇÕ´Ï´Ù.
Delphi ¸Þ´ºÀÇ File/Open.. À¸·Î Program FilesCommon FilesSystemadomsado15.dll ÆÄÀÏÀ» ¿±´Ï´Ù. ¾Æ·¡ ±×¸²°ú °°ÀÌ ÆÄÀÏÇü½ÄÀ» Type Library(*.tlb;*.dll;..)·Î ÁöÁ¤ÇØ¾ß º¼ ¼ö ÀÖ½À´Ï´Ù.



¾Æ·¡¿Í °°ÀÌ ADODB °´Ã¼¿¡ ´ëÇÑ Á¤º¸°¡ ³ªÅ¸³³´Ï´Ù.



Type Library Viewer¿¡¼­ Refresh Implementation ¹öÆ°À» ´­·¯ÁÖ°í Delphi¿¡¼­ F12 Å°¸¦ ´­·¯ Form/Unit toggleÀ» ½ÃÅ°¸é ADODB_TLB.pas ¶ó´Â ÆÄÀÏÀÌ »ý¼ºµË´Ï´Ù. ÀÌ ÆÄÀÏÀ» ¿ì¸®°¡ ¸¸µå´Â ÇÁ·ÎÁ§Æ®¿¡ Æ÷ÇÔ½ÃÄÑ ÁÖ¼¼¿ä.
ADO °´Ã¼¸¦ »ç¿ëÇÏ´Â ¹æ½ÄÀº ¾Æ·¡¿Í °°½À´Ï´Ù.
procedure TWebModule1.WebModule1SomeAction(Sender: TObject;
Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
var
rs, conn, vTemp : OleVariant; // Object¸¦ ¹ÞÀ» º¯¼ö
sConn, sQuery, sResult : string;
begin
conn := unassigned;
rs := unassigned; // ÃʱâÈ­
try
try
conn := CreateOleObject('ADODB.Connection'); // connection »ý¼º
conn.Open('dsn1', 'sa', '', -1); // ODBC DSN, user id, password
rs := CreateOleObject('ADODB.RecordSet'); // recordset »ý¼º

// SELECT¹®
sQuery := 'select * from TABLE1';
rs.Open(sQuery, conn, adOpenStatic, adLockReadOnly, adCmdText); // Connection °´Ã¼ »ç¿ë
sResult := '';
while not rsReady.EOF do
begin
sResult := sResult + rs.Fields.Item['SOME_FIELD1'].Value + rs.Fields.Item['SOME_FIELD2'].Value;
rs.MoveNext; // ´ÙÀ½ record·Î À̵¿
end;
rs.Close; // recordset close

// UPDATE¹®
sQuery := 'update TABLE1 set SOME_FIELD1 = 123';
sQuery := sQuery + ' where SOME_FIELD2 = 1';
conn.Execute(sQuery, vTemp, adCmdText);
except
on E : Exception do
begin
// ¿¡·¯Ã³¸®
end;
end;

finally
if rs.State = adStateOpen then // recordset close¸¦ È®½ÇÇÏ°Ô
rs.Close;
rs := unassigned; // ¸Þ¸ð¸® ÇØÁ¦
conn.Close; // connection close¸¦ È®½ÇÇÏ°Ô
conn := unassigned; // ¸Þ¸ð¸® ÇØÁ¦
end;
end;

ADO´Â ODBC ¶Ç´Â OLEDB Provider¸¦ »ç¿ëÇÏ¿© µ¥ÀÌÅͺ£À̽º¿Í ¿¬°áµË´Ï´Ù. À§ÀÇ ¿¹Á¦´Â ODBC¸¦ »ç¿ëÇÑ ¹æ½ÄÀÔ´Ï´Ù. ODBC¸¦ »ç¿ëÇÏ´Â °æ¿ì, À¥¼­¹öÀÇ ODBC Data Source¿¡ DSN(Data Source Name)ÀÌ ¼³Á¤µÇ¾î ÀÖ¾î¾ß ÇÕ´Ï´Ù. À§ÀÇ ¿¹¿¡¼­´Â 'dsn1'À̶ó´Â À̸§ÀÇ SQL Server data source°¡ ¹Ì¸® ¼³Á¤µÇ¾î ÀÖ¾î¾ß ÇÑ´Ù´Â ¾ê±âÀÔ´Ï´Ù.
SQLServer OLEDB Provider¸¦ »ç¿ëÇÏ´Â °æ¿ì, connection stringÀ» ¾Æ·¡¿Í °°ÀÌ ¹Ù²Ù¾îÁÖ¸é µË´Ï´Ù.
conn.Open('Provider=SQLOLEDB;Data Source=111.111.111.111;database=dbname;User Id=sa;Password=;');

Data Source¿¡ DB¼­¹öÀÇ IP Address¸¦ ÁÖ°í(À¥¼­¹ö¿¡¼­´Â TCP/IP·Î DB¼­¹ö¿¡ ºÙµµ·Ï ¼³Á¤ÇØÁÖ¾î¾ß ÇÕ´Ï´Ù) database¿¡ DB¸í, ±×¸®°í DB user Á¤º¸¸¦ ÁÝ´Ï´Ù. ÀÌ connection stringÀº DBÀÇ Á¾·ù¿¡ µû¶ó ´Ù¸¨´Ï´Ù.
ODBC¿Í OLEDB Provider Áß ¾î¶² °ÍÀ» »ç¿ëÇØ¾ß µÇ´À³Ä.. Microsoft¿¡¼­´Â OLEDB Provider¸¦ ±ÇÀåÇÕ´Ï´Ù. ƯÈ÷ SQLServer6.5 µ¥ÀÌÅͺ£À̽º¿Í MDAC 2.1GA ¹öÁ¯ ÀÌ»óÀ» »ç¿ëÇÏ°í ÀÖ´Ù¸é, ¹Ýµå½Ã OLEDB Provider ¹æ½ÄÀ» »ç¿ëÇϽñ⠹ٶø´Ï´Ù. ODBC ¹æ½ÄÀ¸·Î Çصµ µÇ±ä ÇÏÁö¸¸ ±× ¼º´É¿¡¼­ ¿ùµîÇÑ Â÷ÀÌ°¡ ³³´Ï´Ù. Âü°í·Î ¸»¾¸µå¸®¸é, ÀÌ°ÍÀº ASP(Active Server Page)¿¡¼­ ADO¸¦ »ç¿ë ÇÒ ¶§¿¡µµ µ¿ÀÏÇÏ°Ô Àû¿ëµË´Ï´Ù.
ODBC API (Custom Component) »ç¿ë
Á¦°¡ Å×½ºÆ®Çغ» ¹Ù·Î´Â ADOº¸´Ù ODBC API¸¦ »ç¿ëÇÏ´Â °ÍÀÌ ¼Óµµ°¡ ºü¸¨´Ï´Ù. PentiumPro 200 * 2 CPU, 128M ¸Þ¸ð¸®ÀÇ À¥¼­¹ö¿¡¼­ ½ºÆ®·¹½º Å×½ºÆ®¸¦ ÇßÀ» ¶§ ODBC API¸¦ »ç¿ëÇÑ ¸ðµâÀÌ ADO ¸ðµâº¸´Ù ´ë·« 1.5¹è ÀÌ»óÀÇ request¸¦ ó¸®ÇÏ´õ±º¿ä. Delphi 5.0 ¹öÁ¯¿¡ Æ÷ÇÔµÈ ADO ÄÄÆ÷³ÍÆ®´Â ¸ð¸£°Ú½À´Ï´Ù.. ³ªÁß¿¡ ±âȸ°¡ µÇ¸é Å×½ºÆ®Çؼ­ ¾Ë·Áµå¸®ÁÒ.
ODBC API´Â ±× ¼Óµµ°¡ ºü¸¥ ¹Ý¸é »ç¿ëÇϱâ´Â ¾î·Æ½À´Ï´Ù. ÀÎÅͳݿ¡ º¸¸é ODBC API¸¦ »ç¿ëÇÏ¿© DelphiÀÇ TDatabase, TTable, TQuery, TStoredProc ¿Í Èí»çÇÏ°Ô ¸¸µé¾î³õÀº ÄÄÆ÷³ÍÆ®µéÀ» ±¸ÇÒ ¼ö ÀÖ½À´Ï´Ù. Á¦ ȨÆäÀÌÁö¿¡µµ ¸µÅ©¸¦ °É¾î³õ¾Ò´Âµ¥ http://delphi.icm.edu.pl ·Î °¡¼Å¼­ °Ë»öÇغ¸½Ã¸é ±¸ÇÒ ¼ö ÀÖ½À´Ï´Ù.
»ç¿ë¹æ¹ýÀº DelphiÀÇ µ¥ÀÌÅͺ£À̽º °ü·Ã ÄÄÆ÷³ÍÆ®¿Í °ÅÀÇ ÀÏÄ¡ÇÕ´Ï´Ù. ¸î °¡Áö ¾È¸Ô´Â ¼Ó¼º(¿¹¸¦ µé¾î TQueryÀÇ RecordCount °°Àº °Í)ÀÌ ÀÖÁö¸¸ ¼Óµµ¸¦ ºñ·ÔÇÏ¿© ¸ÖƼ¾²·¹µå¸¦ ¿ÏÀüÇÏ°Ô Áö¿øÇϱ⠶§¹®¿¡ Àû±Ø ÃßõÇص帳´Ï´Ù.
ODBC ÄÄÆ÷³ÍÆ® ÆÐÅ°Áö¸¦ ¼³Ä¡ÇÑ ÈÄ WebModuleÀ§¿¡ ¿Ã·Á³õ°í »ç¿ëÇÏ½Ã¸é µË´Ï´Ù. »ç¿ë¿¹´Â µéÁö ¾Ê°Ú½À´Ï´Ù. Á÷Á¢ Çغ¸¼¼¿ä. Delphi ÄÄÆ÷³ÍÆ®¿Í °ÅÀÇ ¶È°°°Åµç¿ä.
PageProducer, ODBC ÄÄÆ÷³ÍÆ®ÀÇ Á¾ÇÕÈ°¿ë
Á¦°¡ ÀÛ¼ºÇÏ´Â À¥¾îÇø®ÄÉÀ̼ÇÀº ÀÌ µÎ °¡Áö¸¦ Á¶ÇÕÇÏ¿© ¸¸µì´Ï´Ù. HTML ÅÛÇø´À» ¸¸µé¾îµÎ°í, DB¿¡¼­ ¿øÇÏ´Â Á¤º¸¸¦ »Ì¾Æ¿Â ÈÄ replace½ÃÅ°´Â °ÍÀÌÁÒ. ÀÀ¿ëÀ» Àß ÇÏ¸é ±×¸® ¾î·ÆÁö ¾Ê°Ô, ºü¸¥ ½Ã°£³»¿¡ À¥ÇÁ·Î±×·¡¹ÖÀ» ÇÒ ¼ö ÀÖ½À´Ï´Ù.

ÀÛ¼º ³¯Â¥ : 2008-06-23