Wednesday, August 18, 2010

How to place or pass the selected value from a datgrid to the select statement?

For instance...


in datagrid we are having check box.. bound to it....


i am goin to display the column name in it...


user can select or check as many columns he want


suppose if user selects three column means ... these three column should get placed in the select query..


for instance...


if user select order id,order name from order table means..


what should i get is


str=';select orderid,ordername from order';


the column name must be append to str only during run time...


these process are goin to take place in run time... hence table name ,column name will change based on the selection from the user


help me out to overcome the problem...


any tutorial link or code 'll help me lot...


urgent .. make it fast..


i'll be thank ful for you..


thanks in advance........How to place or pass the selected value from a datgrid to the select statement?
I suppose as follows :





Datagrid1


Column1 Column2 Column3 and so on





now user selects Column1 and column3





first store column checked value as follows:





Dim varC1 as String


if not isnull(Me.datagrid1.Column(0) or _


Me.datagrid1.Column(0) %26lt;%26gt; ';'; Then


varC1=Trim(varC1) %26amp; Me.datagrid1.Column(0).Value %26amp; ';,';


Endif





if not isnull(Me.datagrid1.Column(1) or _


Me.datagrid1.Column(1) %26lt;%26gt; ';'; Then


varC1=Trim(varC1) %26amp; Me.datagrid1.Column(1).Value %26amp; ';,';


Endif





if not isnull(Me.datagrid1.Column(2) or _


Me.datagrid1.Column(2) %26lt;%26gt; ';'; Then


varC1=Trim(varC1) %26amp; e.datagrid1.Column(2).Value


Endif





str=';SELECT '; %26amp; varC1 From urTableName





before executing SQL place Stop beneath str and check if it shows correct value.

No comments:

Post a Comment