ʹÓÃVB½«Excelµ¼Èëµ½SqlÖÐ
ʹÓÃVB°ÑExcelµ¼Èëµ½SqlÊý¾Ý¿âÖУ¬ÆäʵÓм¸ÖÖ·½·¨¡£
ÏÂÃæÎÒ½éÉܵÄÕâÖÖ·½·¨£¬½ÏΪ¼òµ¥¡£
ÆäʵÕâÖÖ·½·¨µÄ»°£¬ÊÇÖ±½ÓʹÓÃT-SQL²Ù×÷µÄ£¬Òò´Ë£¬µ½ÁËVBÀïÃ棬ֱ½ÓeccuteÕâ¸ö´úÂë¾ÍOKÁ˵ġ£
-----------------------------------------------------ÏÂÃæÊÇÔÚT-sqlÖеÄÓï¾ä
if object_id('NewTable') is not null/*ÅжϱíNewTableÊÇ·ñ´æÔÚ£¬Èç¹û´æÔÚÔòɾ³ýËü*/
drop table NewTable
Select * Into NewTable from OpenDataSource('Microsoft.Jet.OLEDB.4.0'," _
& "'Data Source=" & ExcelÎļþÃû£¨¾ø¶Ô·¾¶£© & _
";User ID=Admin;Password=;Extended properties=Excel 5.0')...[¹¤×÷±íÃû]
-----------------------------------------------------ÉÏÃæÊÇÔÚT-sqlÖеÄÓï¾ä
ÕâÑù£¬¾Í°ÑÕâ¸öExcel¹¤×÷±íÍêÕûµÄµ¼Èëµ½Sqlµ±Ç°Êý¾Ý¿âϵÄNewTableµÄ±íÖÐÁË¡£
Èç¹ûÏëµ½VBÀïÃæʹÓã¬ÔòÁ¬½Óµ½Õâ¸öÊý¾Ý¿â£¬²¢ÇÒʹÓÃExcuteÖ´ÐÐÉÏÃæµÄT-SQLÓï¾ä¼´¿É¡£
Ïà¹ØÎĵµ£º
ϵͳ»·¾³£ºWindows 7
Èí¼þ»·¾³£ºVisual C++ 2008 SP1 +SQL Server 2005
±¾´ÎÄ¿µÄ£º±àдһ¸öº½¿Õ¹ÜÀíϵͳ
ÕâÊÇÊý¾Ý¿â¿Î³ÌÉè¼ÆµÄ³É¹û£¬ËäÈ»³É¼¨²»¼Ñ£¬µ«ÊÇ×÷ΪÎÒÓÃVC++ ÒÔÀ´±àдµÄ×î´ó³ÌÐò»¹ÊÇ´«µ½ÍøÉÏ£¬ÒÔ¹©²Î¿¼¡£ÓÃVC++ ×öÊý¾Ý¿âÉè¼Æ²¢²»ÈÝÒ×£¬µ«Ò²²»ÊDz»¿ÉÄÜ¡£ÒÔÏÂÊÇÎҵijÌÐò½çÃ棬ºóÃæ ......
µÚ1ÖÖ·½·¨£º
ÆóÒµ¹ÜÀíÆ÷
--¹ÜÀí
--ÓÒ¼üÊý¾Ý¿âά»¤¼Æ»®
--н¨Î¬»¤¼Æ»®
--<ÏÂÒ»²½>
--Ñ¡ÔñÄãÒª±¸·ÝµÄÊý¾Ý¿â
--<ÏÂÒ»²½>Ö±µ½"Ö¸¶¨Êý¾Ý¿â±¸·Ý¼Æ»®"ÕâÏî
--Ö¸¶¨´æ´¢±¸·ÝÎļþµÄλÖÃ,ÕâÀï¸ù¾ÝÐèҪѡÔñ±¸·Öµ½´Å´ø»¹ÊÇ´ÅÅÌ
--µ¥»÷µ÷¶ÈºóÃæµÄ"¸ü¸Ä"°´ ......
Ò»¡¢Êý¾Ý¿â´æ´¢¸ÅÊö
1¡¢Êý¾ÝÎļþÀàÐÍ
· Primary data files:ÿ¸öÊý¾Ý¿â¶¼ÓÐÒ»¸öµ¥¶ÀµÄÖ÷ÒªÊý¾ÝÎļþ£¬Ä¬ÈÏÒÔ.mdfÀ©Õ¹Ãû¡£Ö÷ÒªÊý¾ÝÎļþ²»½ö°üº¬Êý¾ÝÐÅÏ¢£¬»¹°üº¬Óë¸ÃÊý¾Ý¿â½á¹¹Ïà¹ØµÄÐÅÏ¢¡£´´½¨Êý¾Ý¿âʱ£¬Êý¾Ý¿â½á¹¹Ïà¹ØÐÅÏ¢²»½ö´æÔÚÓÚmasterÊý¾Ý¿âÖУ¬Í¬Ê ......
´ÓÍøÉÏËѼ¯µ½µÄVB´úÂ룬ÓÃEXE·½Ê½ÊµÏÖÁËÔ¶³Ì×¢È룬²»¹ýÔÚ·´²¡¶¾Èí¼þµÄ±£»¤Ï£¬ÓпÉÄܵ¼ÖÂ×¢Èëʧ°Ü¡£×ªÌùÕâ¸ö´úÂ룬½ö¹©´ó¼ÒѧϰºÍ²Î¿¼¡£
Ò»¡¢´°¿Ú´úÂ룺
Option Explicit
Private Sub cmdLock_Click()
If LockKeyboard(True) Then
cmdLock.Enabled = False
cmdUnLock.Enabled = Tr ......