using System.Data; using System.Data.SqlClient; // Create a connection to the database SqlConnection conn = new SqlConnection("Data Source=server_name;Initial Catalog=database_name;User ID=user_id;Password=password"); // Create a SQL command SqlCommand cmd = new SqlCommand("SELECT * FROM table_name", conn); // Execute the command and get the results as a DataSet DataSet ds = SQLHandler.ExecuteAsDataSet(cmd); // Loop through the rows in the DataSet and print out the values foreach (DataRow row in ds.Tables[0].Rows) { Console.WriteLine(row["column_name"]); }
using System.Data; using System.Data.SqlClient; // Create a connection to the database SqlConnection conn = new SqlConnection("Data Source=server_name;Initial Catalog=database_name;User ID=user_id;Password=password"); // Create a SQL command for the stored procedure SqlCommand cmd = new SqlCommand("stored_procedure_name", conn); cmd.CommandType = CommandType.StoredProcedure; // Add any parameters needed for the stored procedure cmd.Parameters.AddWithValue("@param_name", "param_value"); // Execute the command and get the results as a DataSet DataSet ds = SQLHandler.ExecuteAsDataSet(cmd); // Loop through the rows in the DataSet and print out the values foreach (DataRow row in ds.Tables[0].Rows) { Console.WriteLine(row["column_name"]); }The SQLHandler class is not a built-in class in C#. It is likely a custom class built by the developer or a package library they imported into their project.