VC ³ÌÐòÖÐÈçºÎÓÃADOÁ¬½ÓSQL Server 2005?
Ê×ÏÈ˵Ã÷Ò»µã£ºVC³ÌÐòÖÐÓÃADOÁ¬½ÓSQL Server 2005 ºÍÁ¬½Ó SQL Server 2000µÄÓï¾äºÍÁ¬½Ó×Ö·û´®ÊÇÍêÈ«Ò»ÑùµÄ£¬ÏÂÃæµÄ´úÂëÊÊÓÃÓÚÁ½¸öÊý¾Ý¿âµÄÁ¬½Ó¡£
ÁíÒ»µã˵Ã÷£ºÈç¹ûÄãÒÔÇ°°²×°¹ýSQL Server 2000£¬ºóÔÚûÓÐжÔصÄÇé¿öÏÂÓÖ°²×°ÁË2005£¬ÄÇôÄã֮ǰÔÚ2000ÖÐÉèÖõÄÓû§ÃûºÍÃÜÂëÔÚ2005Öлᱣ³Ö£¬¼´Ê¹Äã°²×°2005ʱδÉèÖÃÈκÎÓû§ÃûºÍÃÜÂë¡£
ÏÂÃæÊÇVC³ÌÐòÖÐÓÃADOÁ¬½ÓSQL ServerÊý¾Ý¿âµÄÒ»¸öÀý×Ó£º
£¨1£©´´½¨Ò»¸ö»ùÓÚ¶Ô»°¿òµÄ¹¤³Ì£¬¹¤³ÌÃûΪTest¡£
£¨2£©ÔÚStdAfx.hÖе¼ÈëADO¶¯Ì¬Á´½Ó¿â£¬´úÂëÈçÏ£º
#import "C:\Program Files\Common Files\System\ado\msado15.dll" no_namespace\
rename("EOF","adoEOF")
£¨3£©ÔÚCTestApp::InitInstance()Öгõʼ»¯COM»·¾³£º
::CoInitialize(NULL);
×¢Ò⣬ÕâÌõÓï¾äÒ»¶¨Òª·ÅÔÚ“CTestDlg dlg;”ÕâÌõÓï¾äµÄÇ°Ã棬·ñÔòÔÚCTestDlgµÄº¯ÊýÖÐÁ¬½ÓÊý¾Ý¿â»áÒòÎÞ·¨´´½¨Á¬½ÓʵÀý¶øʧ
°Ü¡£
£¨4£©ÔÚ¶Ô»°¿òµÄÍ·ÎļþÖÐÉùÃ÷ADOÖÇÄÜÖ¸Õë¡£
_ConnectionPtr m_pConnection; //Á¬½Ó¶ÔÏóÖ¸Õë
_RecordsetPtr m_pRecordset; //¼Ç¼¼¯¶ÔÏóÖ¸Õë
£¨5£©ÔÚCTestDlg::OnInitDialog()ÖÐÁ¬½ÓÊý¾Ý¿â£º
try
{
m_pConnection.CreateInstance("ADODB.Connection"); //´´½¨Á¬½Ó¶ÔÏóʵÀý
_bstr_t strConnect="Provider=SQLOLEDB.1;Persist Security Info=False;Initial Catalog=Query;
Data Source=127.0.0.1"; //Á¬½Ó×Ö·û´®£¬ÕâÀïQueryÊÇÊý¾Ý¿âÃû£¬127.0.0.1´ú±í±¾µØÖ÷»ú
Ïà¹ØÎĵµ£º
asc °´ÉýÐòÅÅÁÐ
desc °´½µÐòÅÅÁÐ
ÏÂÁÐÓï¾ä²¿·ÖÊÇMssqlÓï¾ä£¬²»¿ÉÒÔÔÚaccessÖÐʹÓá£
SQL·ÖÀࣺ
DDL—Êý¾Ý¶¨ÒåÓïÑÔ(CREATE£¬ALTER£¬DROP£¬DECLARE)
DML—Êý¾Ý²Ù×ÝÓïÑÔ(SELECT£¬DELETE£¬UPDATE£¬INSERT)
DCL—Êý¾Ý¿ØÖÆÓïÑÔ(GRANT£¬REVOKE£¬COMMIT£¬ROLLBACK)
Ê×ÏÈ,¼òÒª½éÉÜ»ù´¡Óï¾ä£º
1¡¢ËµÃ÷£º´´½¨Êý ......
н¨±í£º
create table [±íÃû]
(
[×Ô¶¯±àºÅ×Ö¶Î] int IDENTITY (1,1) PRIMARY KEY ,
[×Ö¶Î1] nVarChar(50) default 'ĬÈÏÖµ' null ,
[×Ö¶Î2] ntext null ,
[×Ö¶Î3] datetime,
[×Ö¶Î4] money null ,
[×Ö¶Î5] int default 0,
[×Ö¶Î6] Decimal (12,4) default 0,
[×Ö¶Î7] image null ,
)
ɾ³ý±í£º
Drop table [±í ......
ÕâÊÇCSDNÂÛ̳ÀïÃæµÄÒ»¸öÌû×Ó£¬×÷ÕßÊÇ°®Ð¾õÂÞ.ع»ª¡£¸Ð¾õ±È½ÏÈ«Ã棬¾ÍÕûÀíÏÂÀ´ÁË£¬Áô×÷ÒÔºó²Î¿¼±¸Óá£ÔÚ´Ë£¬Ôڴ˸Ðл±¾ÎĵÄ×÷Õß¡£
/*
±êÌ⣺һ¸öÏîÄ¿Éæ¼°µ½µÄ50¸öSqlÓï¾ä(ÕûÀí°æ)
×÷Õߣº°®Ð¾õÂÞ.ع»ª(Ê®°ËÄê·çÓ꣬ÊصñùɽѩÁ«»¨¿ª)
ʱ¼ä£º2010-05-10
µØµã£ºÖØÇ캽ÌìְҵѧԺ
˵Ã÷£ºÒÔÏÂÎåÊ®¸öÓï¾ä¶¼°´ÕÕ²âÊÔÊý¾Ý½øÐ ......
Ò»¡¢Ô¼Êø
Ô¼Êø¶¨Òå¹ØÓÚÁÐÖÐÔÊÐíÖµµÄ¹æÔò£¬ÊÇÇ¿ÖÆÍêÕûÐԵıê×¼»úÖÆ¡£
ʹÓÃÔ¼ÊøÓÅÏÈÓÚʹÓô¥·¢Æ÷¡¢¹æÔòºÍĬÈÏÖµ¡£²éѯÓÅ»¯Æ÷ҲʹÓÃÔ¼Êø¶¨ÒåÉú³É¸ßÐÔÄܵIJéѯִÐмƻ®¡£SQL Server 2005Ö§³ÖÎåÀàÔ¼Êø£º
1. NOT ......
ÓÉÓÚÖÖÖÖÔÒò£¬ÎÒÃÇÈç¹ûµ±Ê±½ö½ö±¸·ÝÁËmdfµµ£¬ÄÇô»Ö¸´ÆðÀ´¾ÍÊÇÒ»¼þºÜÂé·³µÄÊÂÇéÁË¡£
Èç¹ûÄúµÄmdfµµÊǵ±Ç°×ÊÁÏ¿â²úÉúµÄ£¬ÄÇôºÜ½ÄÐÒ£¬Ò²ÐíÄãʹÓÃsp_attach_db»òÕßsp_attach_single_file_db¿ÉÒÔ»Ö¸´×ÊÁϿ⣬µ«ÊÇ»á³öÏÖÀàËÆÏÂÃæµÄÌáʾ×ÊѶ
É豸Æô¶¯´íÎó¡£ÎïÀíµµ°¸Ãû 'C:\Program Files\Microsoft SQL S ......