Reputation: 228
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.
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.
Any help here would be greatly appreciated.
<asp:SqlDataSource ID="GridDataSource" runat="server"
ConnectionString="<%$ ConnectionStrings:Oracle1TestString %>"
ProviderName="<%$ ConnectionStrings:Oracle1TestString.ProviderName %>"
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">
<SelectParameters>
<asp:Parameter Name="BadgeNum" Direction="Input" DbType="String" />
</SelectParameters>
</asp:SqlDataSource>
Here is the code behind (C#):
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();
}
Upvotes: 2
Views: 1421
Reputation: 9389
OK then is your prefix possibly wrong in your select statement
@BadgeNum
vs
:BadgeNum
Upvotes: 1