- ©«¤l
- 11
- ¥DÃD
- 5
- ºëµØ
- 0
- ¿n¤À
- 16
- ÂI¦W
- 0
- §@·~¨t²Î
- win7
- ³nÅ骩¥»
- sp3
- ¾\ŪÅv
- 10
- µù¥U®É¶¡
- 2016-2-9
- ³Ì«áµn¿ý
- 2020-2-21
|
¥»©«³Ì«á¥Ñ algoji3ji3 ©ó 2016-4-17 00:32 ½s¿è
¬ã¨s¥X¨Ó¤F....°Ñ¦Ò¤F³oÓºô¯¸...https://www.1keydata.com/tw/sql/sqlupdate.html
:L- Sub קï()
- rc = Range("A2")
- Range("A6:D100").Select
- Selection.ClearContents
- Range("A2").Select
- '1.³s½u¥N¸¹
- Dim myCon As ADODB.Connection '¶}¸ê®Æ®w
- Dim mywq As ADODB.Recordset '¶}¸ê®Æªí
- '2.«Ø¥ßConnectionª«¥ó
- Set myCon = New ADODB.Connection
- '3.³sµ²¸ê®Æ®w
- 'ÅX°Êµ{¦¡Provider = Microsoft.ACE.OLEDB.12.0
- 'Àɮצì¸mData Source=
- myCon.Open "Provider = Microsoft.ACE.OLEDB.12.0;" & "Data Source=" & ThisWorkbook.Path & "\°e¬~.accdb;"
- '4.«Ø¥ßRecordsetª«¥ó&³sµ²¸ê®Æªí
- Sql = " UPDATE °e¬~ "
- Sql = Sql & " SET ¦ç¸¹ = 'B00004'"
- Sql = Sql & " WHERE ½s¸¹ = '" & rc & "'"
- Set mywq = myCon.Execute(Sql)
- 'mywq.Open Sql, myCon, adOpenDynamic, adLockOptimistic
- '5.Ãö³¬³s½u
- myCon.Close
- '6.¥á±óª«¥ó
- Set mywq = Nothing
- Set myCon = Nothing
-
- Range("A2") = ""
- End Sub
½Æ»s¥N½X- Sub §R°£()
- rc = Range("A2")
- Range("A6:D100").Select
- Selection.ClearContents
- Range("A2").Select
- '1.³s½u¥N¸¹
- Dim myCon As ADODB.Connection '¶}¸ê®Æ®w
- Dim mywq As ADODB.Recordset '¶}¸ê®Æªí
- '2.«Ø¥ßConnectionª«¥ó
- Set myCon = New ADODB.Connection
- '3.³sµ²¸ê®Æ®w
- 'ÅX°Êµ{¦¡Provider = Microsoft.ACE.OLEDB.12.0
- 'Àɮצì¸mData Source=
- myCon.Open "Provider = Microsoft.ACE.OLEDB.12.0;" & "Data Source=" & ThisWorkbook.Path & "\°e¬~.accdb;"
- '4.«Ø¥ßRecordsetª«¥ó&³sµ²¸ê®Æªí
- Sql = " DELETE FROM °e¬~ "
- Sql = Sql & " WHERE ½s¸¹ = '" & rc & "'"
- Set mywq = myCon.Execute(Sql)
- 'mywq.Open Sql, myCon, adOpenDynamic, adLockOptimistic
- '5.Ãö³¬³s½u
- myCon.Close
- '6.¥á±óª«¥ó
- Set mywq = Nothing
- Set myCon = Nothing
-
- Range("A2") = ""
- End Sub
½Æ»s¥N½X |
|