Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Use of variables in an sql query

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

1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

I have now created a button that allows me to reload the current application.

But I still cant figure out how to make the selected variables valid in my sql quer statment.

My button uses this code:

Sub Reload

ActiveDocument.Reload

ActiveDocument.Save

End Sub

View solution in original post

2 Replies
Anonymous
Not applicable
Author

I have now created a button that allows me to reload the current application.

But I still cant figure out how to make the selected variables valid in my sql quer statment.

My button uses this code:

Sub Reload

ActiveDocument.Reload

ActiveDocument.Save

End Sub

Anonymous
Not applicable
Author

I needed to create both one button for reload and three buttons for each variable to save the variables.

When saved I can run the reload and it will ise the variables as needed.

It might be possible to create a save function that saves all three variables at one time. will try to solve that one next.

Big thanks to my self