Example #1
0
        public DataTable dbActionSet(SqlCommand command, databaseAction action)
        {
            //Connecting to a database
            string connectdbbe = ConfigurationManager.ConnectionStrings["dbconnect"].ConnectionString;

            //Declare connecting to a database with the name dbcon
            SqlConnection dbcon;

            //Using the connection
            dbcon = new SqlConnection(connectdbbe);
            command.Connection = dbcon;
            dbcon.Open();
            DataTable result = new DataTable();

            if (action == databaseAction.Execute)
            {
                command.ExecuteNonQuery();
            }
            else if (action == databaseAction.Read)
            {
                SqlDataAdapter ad = new SqlDataAdapter(command);
                ad.Fill(result);
            }
            dbcon.Close();

            return(result);
        }
Example #2
0
 public DataTable dbActionSet(SqlCommand query, databaseAction dba)
 {
     return(db.dbActionSet(query, dba));
 }