title: Connecting to password protected DB VBA
body: <p>Hi im pretty new to VBA and im trying to build a connection with a database protected by a password. This is my code.</p>
  
  <pre><code>Sub CostEntry()
      ActiveWorkbook.Sheets.Add.Name = "SAP Sheet"
  
       sConnString = "SourceType:=0, Source:=ODBC;DSN=SAPDATA32;Description=DATA;UID=shareuser;Jet OLEDB:Database Password=1234;APP=Microsoft Office 2016;WSID=AT;DATABASE=DATA"
  
      ' Create the Connection and Recordset objects.
          Set conn = New ADODB.Connection
          Set rs = New ADODB.Recordset
  
      ' Open the connection and execute.
          conn.Open sConnString
          Set rs = conn.Execute("SELECT MBEW.BWKEY, MBEW.STPRS, MBEW.MATNR" &amp; Chr(13) &amp; "" &amp; Chr(10) &amp; "FROM SAPDATA.dbo.MBEW MBEW" &amp; Chr(13) &amp; "" &amp; Chr(10) &amp; "WHERE (MBEW.BWKEY='1010')")
  
      ' Check we have data.
          If Not rs.EOF Then
      ' Transfer result.
              ActiveWorkbook.Sheets("SAP Sheet").range("A1").CopyFromRecordset rs
      ' Close the recordset
              rs.Close
          Else
              MsgBox "Error: No records returned.", vbCritical
          End If
  
      ' Clean up
          If CBool(conn.State And adStateOpen) Then conn.Close
          Set conn = Nothing
          Set rs = Nothing
  
  End Sub
  </code></pre>
  
  <p>Most of it i also copied from the internet adn i also think it was from stackoverflow. I alwas get the error message "Run-time error '-2147467259 (8000400)': Could not find installable ISAM". I trie inserting the line <code>Provider=Microsoft.ACE.OLEDB.12.0</code>
  but it just gave me another error message.
  Thnak you all in advance.</p>