sql server - using dynamic sql in c# code in visual studio -


I am developing an application in which I have to prepare a report based on staff entries and entries. I do not have experience with databases related applications using dynamic queries. In this particular application, I have to pass dynamic SQL queries.

In this I have to select column names based on user selection and then they will have to pass them in other SQL queries as parameters. Here are the questions ...

  DECLARE @ cols AS NVARCHAR (MAX), @class AS NVARCHAR (maximum) select @cols = STUFF ((SELECT ',' + QUOTENAME (date + Select 'Log In Union', select 'Door', Convert (Four (10), Dordert, 101) XML Path (Choose from '_' + LogName) ('.', 'NVARCHAR (Max)'), 1 (Convert for '', type), (10), Dorardet, 112), 10), Dordreit, 112), Date, LogName Order. , 1, '') set @query = 'select employee, name,' + @ cols + '(employee Select name, convert (four (8), dortream, 108) dormitimate, date + "_" '+ from col col_names (select p.employeeid, p.name, convert (char (10), d. Doordate, 101) change the date, minute (d.doordate) [in], max (d.doordate) [out] from person p left P.employeeid = d.employeeid group p.employeeid, p.name, (char Join Logog D. (10), d.doordate, 101)) SQF Unprivate (in colonel (for [these] to do not, [out]) Unpiv) P Axis (maximum (doortime) for col_names (' + @ Cols + ')) Piv' executed (@coke) y)   

I will use this code in the C # code Industry have found how to make sense no data in this way.

Please help.

Thanks in advance ...

Your best bet is your database In order to create a stored system that performs incoming requests, and execute queries. Here are some more information about stored procedures:

Then you have to make a connection to your database in your C # code:

In the end you will be called your stored procedure using the connection made by you and will need to pass the parameters from your C # code, which has been answered many times over the stack overflow:



Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

jsp - Google line chart x-axis shrinks on transition -

java - Reaching JTextField in a DocumentListener -