2 Replies Latest reply: Nov 16, 2011 12:14 PM by Dan-Ketil Jakobsen RSS

    Use of variables in an sql query

    Dan-Ketil Jakobsen

      Hi.

       

      I have a report where the user first select a period to list all valid batchid for that spesific day.

      When this is done 3 list box are filled with some data.

      1: batch start time, in full timestamp, ie: '12-04-2011 09:00:00'

      2: batch stop time, also in full timestamp.

      3: valves

       

      The user is then required to choose a start- and stoptime, also at least one valve to examine.

      I now need to put these 3 parameters into a sql query statment and reload the report with this values.

      The feedback will be presented as a graph.

       

      If run the sql statment without any vairables like the one below, it works.

      SQL EXEC master.dbo.xp_AnalogWideHistory '11-11-2011 07:00:00', '11-11-2011 10:00:00', 10000,'3201L50H007.PV';

       

      BUT, if I change it to use variables it fails.

      SQL EXEC master.dbo.xp_AnalogWideHistory '$(vBatchStartTime)', '$(vBatchStopTime)', 10000, '$(vTag)';

       

      I have created 3 textboxes where I display the variables, and that seems to be correct.

       

      I have not created any button for the user to reload, I just use ctrl+R, and obviously that is not how we should do it.

       

      How do I create a function so that the user can reload after all valid chooses have been made?

       

      Any hint or ideas?

       

      Thanks in advance.

       

      Dan