0

i need create query dynamically in my .cs page. Actually what happens in my application is user can pass the column name and Table names from the page. by using those parameters(columns and tables) we need build Select query . we need retrieve those values from database and show in text format to user.there may multiple table and single table have multiple columns also.

please try yo help how to do this ny using asp.net3.5 and c3.net

2 Answers 2

2

So you need to have a dynamic query that populates its columns as per users requirement. It is not achievable but I have a nearby solution of it.

You can specify from which tables you want data and then using system functions create dynamic query of yours and get it done.

Sign up to request clarification or add additional context in comments.

Comments

0

If nothing else, just create the query string dynamically and then pass it to the ADO.NET routines.

string qry = String.Format("SELECT {0} FROM Table", colName);

4 Comments

hi thanks but my user can pass multiple columns from single table or multiple tables.i need to take all the value from multiple tables Ex: Cust Id from customers and Store Id from ,store address from Stores So i need to take 3 coloumn values from 2 table or more some times how it can be done?
I don't understand what you are asking. I was just showing an example since you haven't been that specific. Are you asking how to modify a string so that it has the right query. Where are you getting stuck exactly?
Actualy i unable to bind multiple columns from multiple table and unable join multiple tables dynamically. iam getting deatails from user is coloumn nams and tables names only by using those i need to retrieve values and shown to the Users.
@santhosh - it is very bad design to have the user the ability to select which columns/tables they want to query upon. What if they type SELECT 1 GO DROP TABLE Customers?? If you want to give the user this much control, at least use something like a GridView.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.