I use combobox in my form, and add items for example fristName, lastName, age
I want when user one of this item and type in textbox expression,fill
datagridview result query
my stored procedure:
ALTER PROCEDURE dbo.StoredProcedure7
@orderby as nvarchar(10),@searchText as nvarchar(50)
AS
begin
select * from Table2
WHERE
@searchText=
CASE @orderby
WHEN 'frirstName' THEN id2
WHEN 'lastName' THEN id1
WHEN 'age' THEN id3
END
end
but this procedure has error and doesn't show anything in datagrid
when i chane nvarchar(max) to nvarchar(50) and use this code to my form:
dataGridView1.DataSource = dc.StoredProcedure8(comboBox1.SelectedItem.ToString(), texbox.Text);
Conversion failed when converting the nvarchar value 'dd' to data type int.