我有这个存储过程:
CREATE PROCEDURE SearchEmployee
@EmployeeID int,
@EmployeeName nvarchar(256),
@Address nvarchar(256),
AS
Select EmployeeId, EmployeeName, Address
From Employee
Where
EmployeeID = @EmployeeID OR
EmployeeName LIKE '%' + @EmployeeName+ '%' OR
Address LIKE '%' + @Address+ '%'
然后在我的 Winforms 中,当comboBox1.Text
=ALL
using (SqlCommand mySqlCommand1 = new SqlCommand("dbo.SearchEmployee", myDatabaseConnection))
{
mySqlCommand1.CommandType = CommandType.StoredProcedure;
if (comboBox1.Text == "ALL")
{
mySqlCommand1.Parameters.AddWithValue("@EmployeeID", textBox1.Text);
mySqlCommand1.Parameters.AddWithValue("@EmployeeName", textBox1.Text);
mySqlCommand1.Parameters.AddWithValue("@Address", textBox1.Text);
}
}
现在我会怎么做comboBox1.Text
=EmployeeID
像这样的东西:?
if (comboBox1.Text == "ALL")
{
mySqlCommand1.Parameters.AddWithValue("@EmployeeID", textBox1.Text);
mySqlCommand1.Parameters.AddWithValue("@EmployeeName", novalue);
mySqlCommand1.Parameters.AddWithValue("@Address", novalue);
}