Assuming that your Sql connection is already created and also your sql command. This code can be called; you pass you sql command and your connection variable to it, it will return a datatable back to you to process and display in your form.
public DataTable ProcessCommand(string sql, SqlConnection conn)
SqlCommand _MiscCommand = default(SqlCommand);
if (conn.State == ConnectionState.Closed)
_MiscCommand = new SqlCommand(sql, conn);
DataSet rsMiscAdapter = new SqlDataAdapter(_MiscCommand);
DataTable table = new DataTable();
catch (Exception )