Exemple #1
0
        public static DataTable GetAllRecords(String qry)
        {
            DataTable ds = new DataTable();

            try
            {
                SqlDataAdapter da;
                SqlConnection  cn = mycon();
                da = new SqlDataAdapter(qry, cn);
                da.Fill(ds);
                cn.Close();
                return(ds);
            }
            catch (Exception ex) {
                GenHelper g = new GenHelper();
                g.logerror(ex);
                return(ds);
            }
        }
Exemple #2
0
        public static SqlConnection mycon()
        {
            String        Constr = ConfigurationManager.ConnectionStrings["Remotestr"].ConnectionString;
            SqlConnection cn     = new SqlConnection();

            try
            {
                cn.ConnectionString = Constr;
                if (cn.State != ConnectionState.Open)
                {
                    cn.Open();
                }
                return(cn);
            }
            catch (Exception ex)
            {
                GenHelper g = new GenHelper();
                g.logerror(ex);
                return(cn);
            }
        }
Exemple #3
0
        public static Boolean NonQuery(String Qry)
        {
            Boolean Executed = false;

            try
            {
                SqlCommand cmd = new SqlCommand();
                cmd.Connection  = mycon();
                cmd.CommandText = Qry;
                int numrow = cmd.ExecuteNonQuery();
                if (numrow > 0)
                {
                    Executed = true;
                }
                cmd.Connection.Close();
                return(Executed);
            }
            catch (Exception ex)
            {
                GenHelper g = new GenHelper();
                g.logerror(ex);
                return(Executed);
            }
        }