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

excel©Mms sql

·íµ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 : ÁÀ¨¥¹³¤@¦·²±¶}ªºÂAªá¡A¥~ªí¬üÄR¡A¥Í©Rµu¼È¡C
ªð¦^¦Cªí ¤W¤@¥DÃD