私はこのストアドプロシージャを持っています:
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);
}