I have a project about searching database with given statements from a Windows form but I couldn't write the correct command for searching SQL. My code:
int? value;
if (this.textBox2.Text == "" || this.textBox2.Text == null)
value = null;
else
value = Convert.ToInt32(this.textBox2.Text);
SqlCommand command = new SqlCommand(
@"SELECT *
FROM Billing
INNER JOIN Payment ON Payment.payment_id = Billing.billing_type
INNER JOIN Customer ON Customer.customer_id = Billing.billing_customer
WHERE billing_id like '%" + textBox5.Text.ToString() + "%'
AND billing_type like '%" + comboBox2.SelectedValue + "%'
AND Billing.billing_cost > " + value + "", connection);
SqlDataReader reader = command.ExecuteReader();
The problem is that when I enter 3000 to textBox2
(I controlled that it is reading 3000) searching is not working and display nothing. Also there is no exception thrown.
Did I write the command or not?