I have searched around the internet but I couldn't find a solution. I want to do this:
if (Convert.ToString(form1.searchBox.SelectedItem) == "Date")
{
val = (sender as TextBox).Text;
sqlCmd = new SqlCommand(
"SELECT * FROM ["TableName"] WHERE ["Date"] LIKE '" +
filterFunc().Trim() + "%'", connection);
}
So I have a Searchbox (Textbox) where one can type something in and it is shown in the database. That works fine for integers and strings but somehow he got problems with the date value above (it's typed as "date" in my SQL database). When I want to grab values I get errors. I tried to Convert and Cast it within the SQL string and in C# but nothing helps!