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("", msSqlConnection);
msSqlCommand.CommandType = System.Data.CommandType.Text;
msSqlCommand.CommandText = "SELECT tagname, SiloNum FROM HMI_SiloStatus WHERE SiloNum IN (207,215,227,231)";
' Map in the Data Adapter
msSqlDataAdapter = new System.Data.SqlClient.SqlDataAdapter(msSqlCommand);
dataSet = new System.Data.DataSet();
msSqlDataAdapter.Fill(dataSet);
'Do something with the dataSet...
' Commit and close the connection
dataSet.Dispose();
catch
' Something went wrong, rollback
'LogError(System.String.Format("{0}: SQL Error {1}: {2}","Retrieve Brabender Data",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;