erzfezsf

hello

i am trying to implement a multiple criteria search form, so far I have written the stored procedure which contains the dynamic sql.

I have a windows form with some search fields and a datagridview to show the search results.

what is the best way to implement the link between the form and the database

the storded procedure can receive a variable number of parameters, but always returns the same number of fields.



Re: Windows Forms Data Controls and Databinding Search form dynamic sql

Rong-Chun Zhang - MSFT

Hi erzfezsf

Your stored procedure may be something like:

Code Snippet

CREATE PROCEDURE Sel_Query

@Columns varchar(1000),

@tbName varchar(50),

@Condition varchar(1000)

AS

BEGIN

Declare @sql varchar(2500)

set @sql = 'Select '+@Columns+' from '+@rbName+' where '+@Condition

EXEC @sql

END

GO

Use several comboboxes to show tables in the database and columns in these tables. Set parameters for this stored procedure via SqlParameter.

Hope it helps.

Regards.