Note that there are some explanatory texts on larger screens.

plurals
  1. POPassing String through C# Code Behind to SQL in .ASPX
    primarykey
    data
    text
    <p>I am pretty new at working with this kind of thing so forgive me if my question seems too easy. I have been trying for a while at this and have searched through every relevant article I can find but I cannot get my code to work.</p> <p>I want to pass a string from 'BadgeNum.Text' through a parameter on the other side and have it execute a query. I cannot get the value to pass correctly and thus cannot get any records to appear out of my query. I have tested the query multiple times using the hard-coded data and it works fine.</p> <p>Any help here would be greatly appreciated.</p> <pre><code>&lt;asp:SqlDataSource ID="GridDataSource" runat="server" ConnectionString="&lt;%$ ConnectionStrings:Oracle1TestString %&gt;" ProviderName="&lt;%$ ConnectionStrings:Oracle1TestString.ProviderName %&gt;" SelectCommand="SELECT MODEL_NUMBER, SERIAL_NUMBER, DEFECT_CODE, RECORD_DATE, RECORD_TIME, PRODUCTION_DATE, AUDIT_TYPE FROM AUDITENT WHERE AUDITOR_BADGE = @BadgeNum" onselecting="GridDataSource_Selecting"&gt; &lt;SelectParameters&gt; &lt;asp:Parameter Name="BadgeNum" Direction="Input" DbType="String" /&gt; &lt;/SelectParameters&gt; &lt;/asp:SqlDataSource&gt; </code></pre> <p>Here is the code behind (C#):</p> <pre><code>protected void Page_Load(object sender, EventArgs e) { BadgeNum.Text = "0205096"; Parameter badge = new Parameter(); badge.DefaultValue = BadgeNum.Text; badge.Type = TypeCode.String; badge.Name = "BadgeNum"; GridDataSource.SelectParameters.Add(badge); GridDataSource.DataBind(); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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