我有下面的代码在后面的代码为btnShowReport_Click
:忽略某些文本框在查询
SqlDataSource1.SelectParameters.Clear();
SqlDataSource1.SelectParameters.Add("username", txtUsername.Text);
SqlDataSource1.SelectParameters.Add("printer", ddlPrinter.Text);
SqlDataSource1.SelectParameters.Add("to", Date.convertDateSolar2Gregorian(txtDateFrom_datepicker.Text));
SqlDataSource1.SelectParameters.Add("from", Date.convertDateSolar2Gregorian(txtDateTo_datepicker.Text));
SqlDataSource1.SelectCommand = "SELECT * FROM JobLog WHERE [email protected] and [email protected] and TimeSubmitted between @to and @from";
我想,当用户不填写一些文本框,在查询后,文本框的标准被忽略在查询中。 我希望你明白我想要什么。