ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

excel©Mms sql

excel©Mms sql

½Ð°Ý¦U¦ì¥ý¶i¡G¦pªG¥Îexcel  ©Mdde¨Ó§ì¨ú¸ê®Æ¡A¬O§_¯à§Y®É¦s¤Jms sql¡HÁÂÁ¡C

¦^´_ 1# leo1889
³o°ÝÃD¤Ó¶W¥X·Q¹³¤F¡AExcel ³£¯à»P Acess ¸ê®Æ³B²z¤F¡A
§A»¡¯à¤£¯à»P MySQL Ápµ²©O¡H

TOP

¥¨¶°¤¤¥Îrecordset¡Bconnection¨âºØª«¥ó³z¹LSQLOLEDB§Y¥i³s¨ìSQL SERVER¤F¡C
uranus

TOP

·íµM¥i¥H
°Ñ¦Ò³oÃ䪺»¡©ú "tomliu888.blogspot.tw/2016/04/excel-ms-sql-vba.html"
¦]¤£¯à¶K³sµ², ©Ò¥H§â¤º®e¶K¤W¨Ó
Sub connectSQL()
    Dim Conn As ADODB.Connection
    Dim sConnect As String
    Dim strSqlInstance As String
    Dim strSqlDB As String
    Dim strSqlUser As String
    Dim strSqlPWD As String
    ' strSqlInstance = "SERVER_NAME\INSTANCE"
    ' ¦pªG¦øªA¾¹¥u¦³¸Ë¤@¦¸ SQL¡A´N¥u­n¿é¤J¦øªA¾¹¦WºÙ
    strSqlInstance = "Your SQL Server Name or IP Address"
    strSqlDB = "Your Database Name"
    strSqlUser = "sa"
    strSqlPWD = "password"
    sConnect = "Provider=SQLOLEDB"
    sConnect = sConnect & ";DATA SOURCE=" & strSqlInstance & ";Initial Catalog=" & strSqlDB
   ' ¦pªG§â User ID=...;Password=... §ï¦¨ "Integrated Security=sspi;"¡A»{ÃҤ覡´NÅܦ¨ AD µn¤J±b¸¹
    sConnect = sConnect & ";User ID=" & strSqlUser & ";Password=" & strSqlPWD & ";"
    Set Conn = New ADODB.Connection
    Conn.ConnectionString = sConnect
    Conn.Open
   ' ³o¸Ì¿é¤J§A³B²z SQL ªº©R¥O
    Conn.Close
End Sub

TOP

        ÀR«ä¦Û¦b : ¡i»X½ªªº¦Û¥Ñ¡j¤H±`¦b¤°»ò³£¥i¥H¦Û¥Ñ¦Û¦bªº®É­Ô¡A«o³Q³oºØÀH¤ß©Ò±ýªº¦Û¥Ñ»X½ª¡AµêÂY®É¥ú¦Ó²@µLıª¾¡C
ªð¦^¦Cªí ¤W¤@¥DÃD