²¶»ñSqlÒì³£
°ïÖúÀïµÄ,Óï·¨:
BEGIN TRY
{ sql_statement | statement_block }
END TRY
BEGIN CATCH
[ { sql_statement | statement_block } ]
END CATCH
[ ; ]
Òì³£²¿·Ö:
ÔÚ CATCH ¿éµÄ×÷ÓÃÓòÄÚ£¬¿ÉÒÔʹÓÃÒÔÏÂϵͳº¯ÊýÀ´»ñÈ¡µ¼Ö CATCH ¿éÖ´ÐеĴíÎóÏûÏ¢£º
ERROR_NUMBER() ·µ»Ø´íÎóºÅ¡£
ERROR_SEVERITY() ·µ»ØÑÏÖØÐÔ¡£
ERROR_STATE() ·µ»Ø´íÎó״̬ºÅ¡£
ERROR_PROCEDURE() ·µ»Ø³öÏÖ´íÎóµÄ´æ´¢¹ý³Ì»ò´¥·¢Æ÷µÄÃû³Æ¡£
ERROR_LINE() ·µ»Øµ¼Ö´íÎóµÄÀý³ÌÖеÄÐкš£
ERROR_MESSAGE() ·µ»Ø´íÎóÏûÏ¢µÄÍêÕûÎı¾¡£ ¸ÃÎı¾¿É°üÀ¨ÈκοÉÌæ»»²ÎÊýËùÌṩµÄÖµ£¬È糤¶È¡¢¶ÔÏóÃû»òʱ¼ä¡£
Ïà¹ØÎĵµ£º
Public Function GetDataTable()
Dim myComm As New SqlClient.SqlCommand("SELECT cauth_id,cauth_name,igrade,csupauth_id,csupauth_name from MAIN_TREE01 ", sqlconnection1)
Dim sdapt As New SqlClient.SqlDataAdapter(myComm)
Dim ds As New DataSet
sdapt.Fill(ds)
R ......
Ò»¡¢ADO¼ò½é
¡¡¡¡ADO(ActiveX Data Object)ÊÇMicrosoftÊý¾Ý¿âÓ¦ÓóÌÐò¿ª·¢µÄнӿڣ¬Êǽ¨Á¢ÔÚOLE DBÖ®Éϵĸ߲ãÊý¾Ý¿â·ÃÎʼ¼Êõ,²»½ö¼òµ¥Ò×Ó㬲¢ÇÒ²»Ê§Áé»îÐÔ.²»Ê§ÎªC++ÀûÓÃÊý¾Ý¿â¿ìËÙ¿ª·¢µÄ²»´íÑ¡Ôñ¡£
¡¡¡¡ÀíÂ۾Ͳ»ÓÃÎÒÔÚÕâ¶ù·Ñ»°ÁË,ÍøÉÏÓкܶà,µ«¹âÊÇÀíÂÛ,Ò²²»ÊDz»¹»µÄ,ADO·ÃÎÊÊý¾ÝµÄ·½·¨ºÜÁé»î,ÈÝÒ×ÈÃÈË»ìÏý.ÍøÉÏ´ó²¿·Ö ......
´æ´¢½ø³Ì¾ÍÊÇ×÷Ϊ¿ÉÖ´ÐжÔÏó´æ·ÅÔÚÊý¾Ý¿âÖеÄÒ»¸ö»ò¶à¸öSQLÃüÁî¡£
¶¨Òå×ÜÊǺܳéÏó¡£´æ´¢½ø³ÌÆäʵ¾ÍÊÇÄÜÍê³ÉÒ»¶¨²Ù×÷µÄÒ»×éSQLÓï¾ä£¬Ö»²»¹ýÕâ×éÓï¾äÊÇ·ÅÔÚÊý¾Ý¿âÖеÄ(ÕâÀïÎÒÃÇ̸ֻSQL SERVER)¡£Èç¹ûÎÒÃÇͨ¹ý´´½¨´æ´¢½ø³ÌÒÔ¼°ÔÚASPÖе÷Óô洢½ø³Ì£¬¾Í¿ÉÒÔ±ÜÃ⽫SQLÓï¾äͬASP´úÂë»ìÔÓÔÚÒ»Æð¡£ÕâÑù×öµÄºÃ´¦ÖÁÉÙÓÐÈý¸ö£º
µÚÒ»¡ ......
Ëæ×ÅB/SģʽӦÓÿª·¢µÄ·¢Õ¹£¬Ê¹ÓÃÕâÖÖģʽ±àдӦÓóÌÐòµÄ³ÌÐòÔ±Ò²Ô½À´Ô½¶à¡£µ«ÊÇÓÉÓÚ³ÌÐòÔ±µÄˮƽ¼°¾ÑéÒ²²Î²î²»Æë£¬Ï൱´óÒ»²¿·Ö³ÌÐòÔ±ÔÚ±àд´úÂëµÄʱºò£¬Ã»ÓжÔÓû§ÊäÈëÊý¾ÝµÄºÏ·¨ÐÔ½øÐÐÅжϣ¬Ê¹Ó¦ÓóÌÐò´æÔÚ°²È«Òþ»¼¡£Óû§¿ÉÒÔÌá½»Ò»¶ÎÊý¾Ý¿â²éѯ´úÂ룬¸ù
¾Ý³ÌÐò·µ»ØµÄ½á¹û£¬»ñµÃijЩËûÏëµÃÖªµÄÊý¾Ý£¬Õâ¾ÍÊÇËùνµÄS ......
ʹÓÃSQL ServerÉí·ÝÑéÖ¤µÇ¼ʱ±¨´í£º
ÎÞ·¨Á¬½Óµ½.\SQLEXPRESS.
Additional information:
Óû§'sa'µÇ¼ʧ°Ü¡£¸ÃÓû§Óë¿ÉÐÅSQL Server Á¬½ÓÎÞ¹ØÁª¡£(microsoft SQL Server,Error:18452£©)
------------------
ÏÂÃæÊÇÓ³Éäʱ±¨µÄ´í£º
´´½¨¶ÔÓÚÓû§“sa”ʧ°Ü¡££¨microsoft.sqlServer.express.smo£©
Additional ......