VCʹÓÃSQLDMO²Ù×÷SQL Server
BOOL StartServer()
{
if(FAILED(CoInitialize(NULL)))
{
AfxMessageBox(_T("Com³õʼ»¯Ê§°Ü"));
return FALSE;
}
_SQLServerPtr spSQLServer;//¶¨ÒåSQL Server¶ÔÏóÖ¸Õë
if(FAILED(spSQLServer.CreateInstance(__uuidof(SQLServer))))
{
AfxMessageBox(_T("ÎÞ·¨½¨Á¢SQL¶ÔÏó"));
return FALSE;
}
CString strServer(_T("SQL Server·þÎñÆ÷Ãû³Æ"));
CString strUserName(_T("µÇ½Ãû"));
CString strPassword(_T("µÇ¼ÃÜÂë"));
try
{
//³¬Ê±ÉèÖÃ
spSQLServer->PutLoginTimeout(10);
spSQLServer->PutApplicationName(_T("MyAppName"));
spSQLServer->PutHostName(_T("MyHostName"));
spSQLServer->PutNetPacketSize(1024);
spSQLServer->Connect(_variant_t(strServer),_variant_t(strUserName),_variant_t(strPassword));
}
catch(_com_error pCE)
{
try
{
//Æô¶¯SQL Server·þÎñÆ÷
spSQLServer->Start(FALSE,_variant_t(strServer),_variant_t(strUserName),_variant_t(strPassword));
}
catch(_com_error pCE)
{
AfxMess
Ïà¹ØÎĵµ£º
ÎÒÃÇÒª×öµ½²»µ«»áдSQL,»¹Òª×öµ½Ð´³öÐÔÄÜÓÅÁ¼µÄSQL,ÒÔÏÂΪ±ÊÕßѧϰ¡¢ÕªÂ¼¡¢²¢»ã×ܲ¿·Ö×ÊÁÏÓë´ó¼Ò·ÖÏí£¡
£¨1£© Ñ¡Ôñ×îÓÐЧÂʵıíÃû˳Ðò(Ö»ÔÚ»ùÓÚ¹æÔòµÄÓÅ»¯Æ÷ÖÐÓÐЧ)£º
ORACLE µÄ½âÎöÆ÷°´ÕÕ´ÓÓÒµ½×óµÄ˳Ðò´¦Àífrom×Ó¾äÖеıíÃû£¬from×Ó¾äÖÐдÔÚ×îºóµÄ±í(»ù´¡±í driving table)½«±»×îÏÈ´¦Àí£¬ÔÚfrom× ......
ÔÚSQLÖпÉÒÔʹÓÃLike½øÐÐÄ£ºý²éѯ£¬ÀýÈç f_stuname like 'a%' ²éѯf_stunameÁÐÒÔa¿ªÍ·µÄ¼Ç¼¡£
µ±ÎÒÃÇÔÚÓ¦ÓÃÖÐʹÓÃ
f_stuname
like '%a%' ʱ£¬Èç¹û
f_stunameÓÐË÷ÒýµÄ»°£¬Õâ¸öË÷ÒýÒ²ÊDz»Ö´ÐеÄ
ÔÚSQLÓÅ»¯ÖÐÕâ¸öд·¨¾ÍÊÇÒ»¸ö²»ºÃµÄSQLÁË¡£
ÄÇôÈçºÎÀ´Ìæ»»Õâ¸öÄØ£¬ÕâÒ»¸ö¾ÍÓõ½ÁËOracleµÄinstrº¯ÊýÁË
ÎÒÃÇ¿ÉÒÔÕâÑù ......
´Ó²©¿ÍÔ°Öп´µ½Ò»ÆªÎÄÕ£¬½éÉÜ´óÈí¼þ¹«Ë¾ÃæÊÔʱ³£³£»á³öµÄÁ½µÀSQLÌ⣨¼û¸½Â¼£©¡£
ÎÒ¾õµÃÊÜÒæºÜ¶à£¬ÔÚ´Ë֮ǰ£¬ÎÒÒ»Ö±¾õµÃ£¬SQL2008ËƺõÌṩÁËÕâ·½ÃæµÄÖ§³Ö£¬µ«¸üµÍµÄ°æ±¾£¬°üÀ¨2005£¬·ÇÓαê×ö²»³öÀ´£¨Ë®Æ½¹»²Ë£©¡£×ܽáÐĵÃÈçÏ£º
1¡¢ Ç¿´óµÄgroup by
1 select stdname,
2 isnull(sum( ......
SqlServer µÄÐÔÄÜ±È Access Ìá¸ßµÄ²»Ö¹Ò»µãÁË¡£
²»¹ý£¬¿ÆÑ´CMSµÄÃâ·Ñ°æ´øµÄÊÇ Access Êý¾Ý¿â¡£
ÓÐûÓа취ת³É mssql µÄÄØ£¿µ±È»¿ÉÒÔ
1, mssqlÖÐн¨Ò»ÕÅ±í£¬È»ºóµ¼Èë access ÀïÃæµÄ±íºÍÊý¾Ý.
Õâ¸öÍøÉÏÓз½·¨£¬²»¶à˵ÁË¡£
2, ÐÞ¸Ä conn.asp µ½ sql server °æ±¾£¬Õâ¸öÒ²¼òµ¥¡£
3, ä¯ÀÀÊý¾Ý£¬Ö±½Ó¾Í¿ÉÒÔ¿´ ......