How can I make the SelectCommand use a textbox from the default page so that I can add that to the where clause? Please include an example I am new to programming and it helps me understand the concept better. thanks in advance.
Example WHERE (BADGE = 10000 +
xBadgeTextBox.Text)?
string Badge = "100000" + Request.Form["xBadgeTextBox"];
<asp:SqlDataSource ID="Time" runat="server"
ConnectionString="<%$ ConnectionStrings:Time %>"
ProviderName="<%$ ConnectionStrings:Time.ProviderName %>"
SelectCommand="SELECT CLOCK_IN_TIME, CLOCK_OUT_TIME, BADGE FROM CLOCK_HISTORY WHERE (BADGE = 100000342)"> // use the badge number instead.
</asp:SqlDataSource>
You’ll want to add parameters to the query and specify them within the SqlDataSource object. Take a look here:
http://msdn.microsoft.com/en-us/library/z72eefad.aspx
Also, please PLEASE be very careful of SQL injection attacks here. At some point you may be tempted to just concatenate the string from the textbox to the select command. Don’t 🙂