<div dir="ltr"><div class="" itemprop="description" style="margin:0px 0px 5px 5px;padding:0px;border:0px;vertical-align:baseline;width:660px;word-wrap:break-word;color:rgb(57,51,24);font-family:'Lucida Grande','Lucida Sans Unicode','Lucida Sans',Tahoma,sans-serif;background-color:rgba(255,255,255,0.529412);font-size:14px!important;line-height:18px!important">
<p style="margin:0px 0px 1em;padding:0px;border:0px;vertical-align:baseline;clear:both">FROM MY POSTING AT: <a href="http://tex.stackexchange.com/questions/180018/luatex-context-connect-to-sql-server?noredirect=1#comment415824_180018">http://tex.stackexchange.com/questions/180018/luatex-context-connect-to-sql-server?noredirect=1#comment415824_180018</a></p>
</div><div class="" itemprop="description" style="margin:0px 5px 5px 0px;padding:0px;border:0px;vertical-align:baseline;width:660px;word-wrap:break-word;color:rgb(57,51,24);font-family:'Lucida Grande','Lucida Sans Unicode','Lucida Sans',Tahoma,sans-serif;background-color:rgba(255,255,255,0.529412);font-size:14px!important;line-height:18px!important">
<p style="margin:0px 0px 1em;padding:0px;border:0px;vertical-align:baseline;clear:both">I am looking to connect ConTeXt to a SQL Server database. I have looked through the manuals, and even read pragma-ade's SQL PDF (which, for me, seems a bit abstract). I am not extremely familiar with Lua but have read up on the language (I am more familiar with JS). For LaTex I used nlatexdb which did the trick, but LaTex isn't able to do what ConTeXt can.</p>
<ul style="margin:0px 0px 1em 30px;padding:0px;border:0px;vertical-align:baseline;list-style-position:initial"><li style="margin:0px 0px 7px;padding:0px;border:0px;vertical-align:baseline;line-height:1.3em;word-wrap:break-word">
<p style="margin:0px 0px 1em;padding:0px;border:0px;vertical-align:baseline;clear:both">The connection needs to use Windows Authentication.</p></li><li style="margin:0px 0px 7px;padding:0px;border:0px;vertical-align:baseline;line-height:1.3em;word-wrap:break-word">
<p style="margin:0px 0px 1em;padding:0px;border:0px;vertical-align:baseline;clear:both">The document is set up as a letter with an environment that it pulls from.</p></li><li style="margin:0px 0px 7px;padding:0px;border:0px;vertical-align:baseline;line-height:1.3em;word-wrap:break-word">
<p style="margin:0px 0px 1em;padding:0px;border:0px;vertical-align:baseline;clear:both">It would be preferable to have the connection and queries be seperate from the letter itself, and be able to place variables into the letter that can be populated through the queries (much like nlatexdb) if possible.</p>
<ul style="margin:0px 0px 0px 30px;padding:0px;border:0px;vertical-align:baseline;list-style:disc"><li style="margin:0px 0px 7px;padding:0px;border:0px;vertical-align:baseline;line-height:1.3em;word-wrap:break-word">example: Dear ??first ??last, Thank you for your interest in ??product... etc.</li>
</ul></li></ul><p style="margin:0px 0px 1em;padding:0px;border:0px;vertical-align:baseline;clear:both">I am rather new to ConText and just starting to get the hang of it, long time latex user, the transition starts off rather confusing, but once it makes sense it opens up a whole toolbox of available tools which is great. Just need this one last tool.</p>
<p style="margin:0px 0px 1em;padding:0px;border:0px;vertical-align:baseline;clear:both">Any help would be much appreciated.</p><p style="margin:0px 0px 1em;padding:0px;border:0px;vertical-align:baseline;clear:both">EDIT:: Honestly I haven't gotten to any point that I felt I could attempt trying the connection. Looking at the SQL PDF from pragma-ade it should look something like:</p>
<pre class="" style="margin-top:0px;margin-bottom:10px;padding:5px;border:0px;font-size:12px;vertical-align:baseline;overflow:auto;width:auto;max-height:600px;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif;background-color:rgb(238,238,238);word-wrap:normal">
<code style="margin:0px;padding:0px;border:0px;vertical-align:baseline;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif;color:rgb(34,34,34);white-space:inherit"><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(0,0,0)">    local presets </span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(20,86,128)">=</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(0,0,0)"> </span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(20,86,128)">{</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(0,0,0)">
    server </span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(20,86,128)">=</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(0,0,0)"> "XXX</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(138,74,11)">\XXX</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(0,0,0)">",
    Database </span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(20,86,128)">=</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(0,0,0)"> "Customer",
    Integrated Security </span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(20,86,128)">=</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(0,0,0)"> "True",
    </span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(20,86,128)">}</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(0,0,0)">
    <a href="http://presets.id">presets.id</a> </span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(20,86,128)">=</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(0,0,0)"> "XXX"
    local template </span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(20,86,128)">=</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(0,0,0)"> </span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(20,86,128)">[[</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(0,0,0)">
    SELECT
    'Control_Content'
    FROM
    'Customer.dbo.Report_Client_Data'
    WHERE
    'Control_Name' LIKE 'Long_Name' AND 'Client_Id' </span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(20,86,128)">=</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(0,0,0)"> 154;
     </span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(20,86,128)">]]</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(0,0,0)">

    local data, keys </span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(20,86,128)">=</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(0,0,0)"> utilities.sql.execute </span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(20,86,128)">{</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(0,0,0)">
    presets </span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(20,86,128)">=</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(0,0,0)"> presets,
    template </span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(20,86,128)">=</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(0,0,0)"> template,
    variables </span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(20,86,128)">=</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(0,0,0)"> </span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(20,86,128)">{}</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(0,0,0)">,
    </span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(20,86,128)">}</span></code></pre><p style="margin:0px 0px 1em;padding:0px;border:0px;vertical-align:baseline;clear:both">
I can't seem to find where or how the connection is being made, except perhaps where utilities.sql.execute is called, but I can't find any information anywhere about such a call in lua or context...<br></p></div></div>