dim msSqlConnection as System.Data.SqlClient.SqlConnection;
dim msSqlCommand as System.Data.SqlClient.SqlCommand;
dim msSqlDataAdapter as System.Data.SqlClient.SqlDataAdapter;
dim dataSet as System.Data.DataSet;
try
' Define and open Connection
msSqlConnection = new System.Data.SqlClient.SqlConnection(
Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE\\ArchestrA\\AuxConfig").GetValue("SQLConnection_HPA")
);
msSqlConnection.Open();
' Setup Command
msSqlCommand = new System.Data.SqlClient.SqlCommand("STP_RMS_RetrieveSiloList", msSqlConnection);
msSqlCommand.CommandType = System.Data.CommandType.StoredProcedure;
' Setup Parameters
msSqlCommand.Parameters.Add("@V_QualityOverride", System.Data.SqlDbType.Bit).Value = b_QualityOverride;
msSqlCommand.Parameters.Add("@V_IngrCode", System.Data.SqlDbType.NVarChar,50).Value = s_IngrCodeLink;
msSqlCommand.Parameters.Add("@V_Line", System.Data.SqlDbType.Int).Value = line;
' Map in the Data Adapter
msSqlDataAdapter = new System.Data.SqlClient.SqlDataAdapter(msSqlCommand);
dataSet = new System.Data.DataSet();
msSqlDataAdapter.Fill(dataSet);
' Populate the Silo List from the dataSet
g_SiloChange.cb_SiloList.DisplayMember = "Display";
g_SiloChange.cb_SiloList.ValueMember = "Tagname";
g_SiloChange.cb_SiloList.DataSource = dataSet.Tables(0);
' Push the Dataset into the app domain
System.AppDomain.CurrentDomain.SetData("BatchingSiloList", dataSet);
' Commit and close the connection
dataSet.Dispose();
msSqlDataAdapter.Dispose();
msSqlCommand.Dispose();
msSqlConnection.Close();
catch
LogError(System.String.Format("{0}: SQL Error {1}: {2}","RetrieveSiloData", error.GetType(), error.Message));
msSqlConnection.Close();
endtry;
' Perform Cleanup
if msSqlConnection <> NULL then msSqlConnection.Dispose(); endif;
if msSqlCommand <> NULL then msSqlCommand.Dispose(); endif;
msSqlDataAdapter = NULL; msSqlCommand = NULL; msSqlConnection = NULL;