CurrentDatabase() private method

private CurrentDatabase ( ) : string
return string
Ejemplo n.º 1
0
        private static ProcedureCacheEntry GetProcData(MySqlConnection connection, string spName)
        {
            string text  = string.Empty;
            string text2 = spName;
            int    num   = spName.IndexOf(".");

            if (num != -1)
            {
                text  = spName.Substring(0, num);
                text2 = spName.Substring(num + 1, spName.Length - num - 1);
            }
            string[] array = new string[4];
            array[1] = ((text.Length > 0) ? text : connection.CurrentDatabase());
            array[2] = text2;
            MySqlSchemaCollection schemaCollection = connection.GetSchemaCollection("procedures", array);

            if (schemaCollection.Rows.Count > 1)
            {
                throw new MySqlException(Resources.ProcAndFuncSameName);
            }
            if (schemaCollection.Rows.Count == 0)
            {
                throw new MySqlException(string.Format(Resources.InvalidProcName, text2, text));
            }
            ProcedureCacheEntry procedureCacheEntry = new ProcedureCacheEntry();

            procedureCacheEntry.procedure = schemaCollection;
            ISSchemaProvider iSSchemaProvider = new ISSchemaProvider(connection);

            string[] restrictions = iSSchemaProvider.CleanRestrictions(array);
            MySqlSchemaCollection procedureParameters = iSSchemaProvider.GetProcedureParameters(restrictions, schemaCollection);

            procedureCacheEntry.parameters = procedureParameters;
            return(procedureCacheEntry);
        }
Ejemplo n.º 2
0
        private static DataSet GetProcData(MySqlConnection connection, string spName)
        {
            int    dotIndex = spName.IndexOf(".");
            string schema   = spName.Substring(0, dotIndex);
            string name     = spName.Substring(dotIndex + 1, spName.Length - dotIndex - 1);

            string[] restrictions = new string[4];
            restrictions[1] = schema.Length > 0 ? schema : connection.CurrentDatabase();
            restrictions[2] = name;
            DataTable procTable = connection.GetSchema("procedures", restrictions);

            if (procTable.Rows.Count > 1)
            {
                throw new MySqlException(Resources.ProcAndFuncSameName);
            }
            if (procTable.Rows.Count == 0)
            {
                throw new MySqlException(String.Format(Resources.InvalidProcName, name, schema));
            }

            // we don't use GetSchema here because that would cause another
            // query of procedures and we don't need that since we already
            // know the procedure we care about.
            ISSchemaProvider isp             = new ISSchemaProvider(connection);
            DataTable        parametersTable = isp.GetProcedureParameters(
                restrictions, procTable);

            DataSet ds = new DataSet();

            ds.Tables.Add(procTable);
            ds.Tables.Add(parametersTable);
            return(ds);
        }
Ejemplo n.º 3
0
        private static ProcedureCacheEntry GetProcData(MySqlConnection connection, string spName)
        {
            string schema = string.Empty;
            string name   = spName;

            int dotIndex = spName.IndexOf("`.`");

            if (dotIndex != -1)
            {
                schema = spName.Substring(1, dotIndex - 1);
                name   = spName.Substring(dotIndex + 3, spName.Length - dotIndex - 4);
            }

            string[] restrictions = new string[4];
            restrictions[1] = schema.Length > 0 ? schema : connection.CurrentDatabase();
            restrictions[2] = name;
            MySqlSchemaCollection proc = connection.GetSchemaCollection("procedures", restrictions);

            if (proc.Rows.Count > 1)
            {
                throw new MySqlException(Resources.ProcAndFuncSameName);
            }
            if (proc.Rows.Count == 0)
            {
                string msg = string.Format(Resources.InvalidProcName, name, schema) + " " +
                             string.Format(Resources.ExecuteProcedureUnauthorized, connection.Settings.UserID, connection.Settings.Server);
                throw new MySqlException(msg);
            }

            ProcedureCacheEntry entry = new ProcedureCacheEntry();

            entry.procedure = proc;

            // we don't use GetSchema here because that would cause another
            // query of procedures and we don't need that since we already
            // know the procedure we care about.
            ISSchemaProvider isp = new ISSchemaProvider(connection);

            string[] rest = isp.CleanRestrictions(restrictions);
            MySqlSchemaCollection parameters = isp.GetProcedureParameters(rest, proc);

            entry.parameters = parameters;

            return(entry);
        }
Ejemplo n.º 4
0
        private static DataSet GetProcData(MySqlConnection connection, string spName)
        {
            string schema = String.Empty;
            string name = spName;

            int dotIndex = spName.IndexOf(".");
            if (dotIndex != -1)
            {
                schema = spName.Substring(0, dotIndex);
                name = spName.Substring(dotIndex + 1, spName.Length - dotIndex - 1);
            }

            string[] restrictions = new string[4];
            restrictions[1] = schema.Length > 0 ? schema : connection.CurrentDatabase();
            restrictions[2] = name;
            DataTable procTable = connection.GetSchema("procedures", restrictions);
            if (procTable.Rows.Count > 1)
                throw new MySqlException(Resources.ProcAndFuncSameName);
            if (procTable.Rows.Count == 0)
                throw new MySqlException(String.Format(Resources.InvalidProcName, name, schema));

            DataSet ds = new DataSet();
            ds.Tables.Add(procTable);

            // we don't use GetSchema here because that would cause another
            // query of procedures and we don't need that since we already
            // know the procedure we care about.
            ISSchemaProvider isp = new ISSchemaProvider(connection);
            string[] rest = isp.CleanRestrictions(restrictions);
            try
            {
                DataTable parametersTable = isp.GetProcedureParameters(rest, procTable);
                ds.Tables.Add(parametersTable);
            }
            catch (Exception) { }

            return ds;
        }
Ejemplo n.º 5
0
    private static ProcedureCacheEntry GetProcData(MySqlConnection connection, string spName)
    {
      string schema = String.Empty;
      string name = spName;

      int dotIndex = spName.IndexOf(".");
      if (dotIndex != -1)
      {
        schema = spName.Substring(0, dotIndex);
        name = spName.Substring(dotIndex + 1, spName.Length - dotIndex - 1);
      }

      string[] restrictions = new string[4];
      restrictions[1] = schema.Length > 0 ? schema : connection.CurrentDatabase();
      restrictions[2] = name;
      MySqlSchemaCollection proc = connection.GetSchemaCollection("procedures", restrictions);
      if (proc.Rows.Count > 1)
        throw new MySqlException(Resources.ProcAndFuncSameName);
      if (proc.Rows.Count == 0)
        throw new MySqlException(String.Format(Resources.InvalidProcName, name, schema));

      ProcedureCacheEntry entry = new ProcedureCacheEntry();
      entry.procedure = proc;

      // we don't use GetSchema here because that would cause another
      // query of procedures and we don't need that since we already
      // know the procedure we care about.
      ISSchemaProvider isp = new ISSchemaProvider(connection);
      string[] rest = isp.CleanRestrictions(restrictions);
      MySqlSchemaCollection parameters = isp.GetProcedureParameters(rest, proc);
      entry.parameters = parameters;

      return entry;
    }