Loads a scenario from a database.

Namespace: WaterSimDCDC
Assembly: WaterSimDCDC_API (in WaterSimDCDC_API.dll) Version: 5.0.0.10 (5.0.0.10)

Syntax

C#
public bool LoadScenario_DB(
	string ScenarioName,
	int year,
	DataTable Source,
	ref SimulationInputs sInputs
)
Visual Basic
Public Function LoadScenario_DB ( _
	ScenarioName As String, _
	year As Integer, _
	Source As DataTable, _
	ByRef sInputs As SimulationInputs _
) As Boolean

Parameters

ScenarioName
Type: System..::..String
Name of the scenario, if empty (="") then the first scenario found is used.
year
Type: System..::..Int32
The year. If 0 then the first year found is used
Source
Type: System.Data..::..DataTable
Datatable Source.
sInputs
Type: WaterSimDCDC..::..SimulationInputs%
[in,out] SimulationInputs.

Return Value

true if it succeeds, false if it fails. If false check isError and GetErrorMessage()

Remarks

This method will load Input Model Parameters (BaseInput and ProviderInput) into a SimulationInputs struct. The Datatable must be a valid WaterSim_DB datatable (see Valid_DataTable However fields for all input parameters do not need to be in the Datatable. This method will load whatever ModelParameter.Fieldname fields it finds. It does not set values in sInputs struct for Model Parameters it finds. It is good practice to fill the sInputs struct with the models current input values before passing it to this method. See example

Examples

CopyC#
try
      {
          OleDbDataAdapter TableAdapter = new OleDbDataAdapter("Select * from " + '[' + tablename + ']', WSim.DbConnection);
          TableAdapter.Fill(DT);
          TableAdapter.Dispose();
          SimulationInputs SI = WSim.ParamManager.GetSimulationInputs();
          if (WSim.LoadScenario_DB("", 0, DT, ref SI))
           {
              if (WSim.ParamManager.SetSimulationInputs(SI))
              {
                  WS_InputPanel.Refresh_Inputs();
              }
          }
      }
      catch (Exception e)
      {
          MessageBox.Show("Whoops " + e.Message);
      }

Exceptions

ExceptionCondition
WaterSimDCDC..::..WaterSim_Exceptionwhen Source datatable is not a valid Watersim_DB datatable.

See Also