title: Connecting to Microsoft SQL Server with Autohotkey?
body: <p>I have an ahk script that I run each day but first, I have to hard code the data into it after I run a query. Is it possible to connect to SQL Server via Autohotkey? This would obviously be ideal. I've read a few articles but haven't had success doing it thus far.</p>
  
  <p>I tried the sample logic below with no luck.</p>
  
  <p>Thanks!</p>
  
  <pre><code>ConnectionString = "Provider=SQLOLEDB.1;Persist Security Info=True;User ID=user;Password=pw;Initial Catalog=db;Data Source=server;Use Procedure for Prepare=1;Auto Translate=True;Packet Size=4096;Use Encryption for Data=False;Tag with column collation when possible=False"
  Query := "select * from tbl"
  Table := ADOSQL(ConnectionString, Query)
  Loop % Table.MaxIndex() - 1 ; We subtract 1 in order to skip one row (which will be the column titles, as we are adding 1 to the counter below).
  {
       CURRENT_ROW := A_Index + 1 ; We add one to our current row counter in order to start on row 2 (skip row 1).
       Loop % Table[CURRENT_ROW].MaxIndex()
       {
            CURRENT_COLUMN := A_Index
            msgbox % Table[CURRENT_ROW, CURRENT_COLUMN]
       }
  }
  </code></pre>