using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;

namespace Library_Red_Diamonds
{
  public  class DataBase
    {
      private SqlCommand cmd;
      private SqlConnection con;
      private SqlDataAdapter da;
      private DataTable dt;

      public void docommand(string ole)
      {
          con = new SqlConnection();
          con.ConnectionString = "Data Source=.\\SQLEXPRESS;AttachDbFilename=|DataDirectory|\\Red-Diamonds-DB.mdf;Integrated Security=True";
          cmd = new SqlCommand();
          cmd.Connection = con;
          con.Open();
          cmd.CommandText = ole;
          cmd.ExecuteNonQuery();
          con.Close();
      }

      public DataTable MySelect(string sql)
      {
          con = new SqlConnection();
          con.ConnectionString = "Data Source=.\\SQLEXPRESS;AttachDbFilename=|DataDirectory|\\Red-Diamonds-DB.mdf;Integrated Security=True";
          cmd = new SqlCommand();
          cmd.Connection = con;
          da = new SqlDataAdapter(cmd);
          dt = new DataTable();
          con.Open();
          cmd.CommandText = sql;
          da.Fill(dt);
          con.Close();
          return dt;
      }
    }
}
