Note that there are some explanatory texts on larger screens.

plurals
  1. POInserting variables into a query string - it won't work!
    text
    copied!<p>Basically i have a query string that when i hardcode in the catalogue value its fine. when I try adding it via a variable it just doesn't pick it up.</p> <p>This works:</p> <pre><code> Dim WaspConnection As New SqlConnection("Data Source=JURA;Initial Catalog=WaspTrackAsset_NROI;User id=" &amp; ConfigurationManager.AppSettings("WASPDBUserName") &amp; ";Password='" &amp; ConfigurationManager.AppSettings("WASPDBPassword").ToString &amp; "';") </code></pre> <p>This doesn't:</p> <pre><code>Public Sub GetWASPAcr() connection.Open() Dim dt As New DataTable() Dim username As String = HttpContext.Current.User.Identity.Name Dim sqlCmd As New SqlCommand("SELECT WASPDatabase FROM dbo.aspnet_Users WHERE UserName = '" &amp; username &amp; "'", connection) Dim sqlDa As New SqlDataAdapter(sqlCmd) sqlDa.Fill(dt) If dt.Rows.Count &gt; 0 Then For i As Integer = 0 To dt.Rows.Count - 1 If dt.Rows(i)("WASPDatabase") Is DBNull.Value Then WASP = "" Else WASP = "WaspTrackAsset_" + dt.Rows(i)("WASPDatabase") End If Next End If connection.Close() End Sub Dim WaspConnection As New SqlConnection("Data Source=JURA;Initial Catalog=" &amp; WASP &amp; ";User id=" &amp; ConfigurationManager.AppSettings("WASPDBUserName") &amp; ";Password='" &amp; ConfigurationManager.AppSettings("WASPDBPassword").ToString &amp; "';") </code></pre> <p>When I debug the catalog is empty in the query string but the WASP variable holds the value "WaspTrackAsset_NROI"</p> <p>Any idea's why?</p> <p>Cheers,</p> <p>jonesy</p> <p><a href="http://www.freeimagehosting.net/uploads/ba8edc26a1.png" rel="nofollow noreferrer">alt text http://www.freeimagehosting.net/uploads/ba8edc26a1.png</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload