예제 #1
0
    public static DataTable SqlDTable2(string strQuery)//DEVUELVE UNA TABLA A PARTIR DE UNA CONSULTA
    {
        DataTable     tabla = new DataTable();
        SqlConnection sConn = ConexionCall.ConexionSql();


        SqlCommand     sqlCmd  = new SqlCommand(strQuery, sConn);
        SqlDataAdapter sqlAdap = new SqlDataAdapter(sqlCmd);

        sqlCmd.CommandTimeout = 10000;

        tabla.Clear();
        try
        {
            sConn.Open();
            sqlAdap.Fill(tabla);
            sqlAdap.Dispose();
            sqlCmd.Dispose();
        }
        catch (Exception)
        {
            tabla.Clear();
        }
        finally
        {
            sConn.Close();
            sConn.Dispose();
        }
        return(tabla);
    }
예제 #2
0
    protected void ConectarSQLServer(string ingresar)
    {
        SqlCommand comando = new SqlCommand(ingresar, ConexionCall.ConexionSql());

        try
        {
            comando.Connection.Open();
            comando.ExecuteNonQuery();
        }
        catch (Exception)
        {
            //  Anthem.Manager.AddScriptForClientSideEval(string.Format("alert('{0}')", ex.Message));
        }
        finally
        {
            comando.Connection.Close();
        }
    }
예제 #3
0
    public string ejecutorBaseString(string sqlQry)
    {
        SqlConnection sConn  = ConexionCall.ConexionSql();
        SqlCommand    sqlCmd = new SqlCommand(sqlQry, sConn);

        try
        {
            sConn.Open();
            sqlCmd.ExecuteNonQuery();
            return("ok");
        }

        catch (Exception ex)
        { return(ex.Message); }

        finally
        {
            sqlCmd.Dispose();
            sConn.Dispose();
            sConn.Close();
        }
    }
예제 #4
0
    public bool ejecutorBase(string sqlQry)
    {
        SqlConnection sConn  = ConexionCall.ConexionSql();
        SqlCommand    sqlCmd = new SqlCommand(sqlQry, sConn);

        try
        {
            sConn.Open();
            sqlCmd.ExecuteNonQuery();
            return(true);
        }

        catch (Exception)
        { return(false); }

        finally
        {
            sqlCmd.Dispose();
            sConn.Dispose();
            sConn.Close();
        }
    }