Click here to Skip to main content
14,872,493 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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:
SQL
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.
Posted
Updated 7-May-12 22:47pm
v4

1 solution

It's Nvarchar(Max) it can not be indexed.
You can not use it in the condition. try another type for example Nvarchar(100).
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900