예제 #1
0
    public static bool ExecuteNonQuery(SqlCommand cmd)
    {
        Conn          fns  = new Conn();
        SqlConnection conn = fns.Connct();

        try
        {
            cmd.Connection = conn;
            if (conn.State == ConnectionState.Closed || conn.State == ConnectionState.Broken)
            {
                conn.Open();
            }
            cmd.ExecuteNonQuery();
            cmd.Dispose();

            return(true);
        }
        catch
        {
            return(false);
        }
        finally
        {
            conn.Close();
            conn.Dispose();
        }
    }
예제 #2
0
    public static DataTable getTable(string sql)
    {
        DataTable     dt   = new DataTable();
        Conn          fns  = new Conn();
        SqlConnection conn = fns.Connct();

        try
        {
            SqlCommand cmd = new SqlCommand();
            cmd.Connection  = conn;
            cmd.CommandText = sql;
            cmd.CommandType = CommandType.Text;
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            da.Fill(dt);
            da.Dispose();
            cmd.Dispose();
        }
        catch
        { }
        finally
        {
            conn.Close();
            conn.Dispose();
        }
        return(dt);
    }
예제 #3
0
    public static DataTable getTable(SqlCommand cmd)
    {
        DataTable     dt   = new DataTable();
        Conn          fns  = new Conn();
        SqlConnection conn = fns.Connct();

        try
        {
            cmd.Connection = conn;
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            da.Fill(dt);
            da.Dispose();
            cmd.Dispose();
        }
        catch
        { }
        finally
        {
            conn.Close();
            conn.Dispose();
        }
        return(dt);
    }