title: Use Shiny App to Query a SQL Server DB
body: <p>I guess I really don't understand this process like I thought I did.  I found the link below, and it seems pretty helpful, but after making only slight modifications, I can't get it to do what I want.</p>
  
  <p><a href="https://stackoverflow.com/questions/42120389/r-shiny-sql-server-query">R Shiny SQL Server Query</a></p>
  
  <p>I just want to launch a webpage and have a user enter a parameter, to be passed into a query.  </p>
  
  <pre><code>library(RODBCext)
  library(shiny)
  
  ui &lt;- shinyUI(
  
    pageWithSidebar(
  
      headerPanel("Hide Side Bar example"),
      sidebarPanel(
        textInput("CATEGORY", "Enter CATEGORY below"),
        submitButton(text="Submit")
      ),
      mainPanel(
        tabsetPanel(
              tabPanel("Data", tableOutput("tbTable"))
        )
  
      )
    )
  )
  
  browser()
  
  server &lt;- function(input, output, session)      
    myData &lt;- reactive({
      req(input$Id)
  
      #connect to database 
      dbhandle = odbcDriverConnect('driver={SQL Server};server=my_server;database=data_WH;trusted_connection=true')
  
      browser()
  
      #build query
      #query = "SELECT * FROM [my_db].[dbo].[my_table] where [CATEGORY] = '1070'"
  query = "SELECT * FROM [my_db].[dbo].[my_table] where [CATEGORY] = ?"
  
      browser()
  
      #store results
      res &lt;- sqlExecute(channel = dbhandle, 
                        query = query,
                        data = list(input$Id),
                        fetch = TRUE,
                        stringsAsFactors = FALSE) 
  
      #close the connection
      odbcClose(dbhandle)
      #return results
      res
    })
  
    output$tbTable &lt;- 
      renderTable(
        myData()
  )
  
  shinyApp(ui = ui, server = server)
  </code></pre>
  
  <p>The SQL string is fine.  I entered browser, to try to debug the script, as described in the link below.</p>
  
  <p><a href="https://shiny.rstudio.com/articles/debugging.html" rel="nofollow noreferrer">https://shiny.rstudio.com/articles/debugging.html</a></p>
  
  <p>browser()</p>
  
  <p>It didn't pause the code; it didn't help me debug the code.  It didn't do anything at all.</p>
  
  <p>Any thoughts anyone?</p>