Пример #1
0
        public NpgsqlParameter AddInParam(string name, bool isNullable, NpgsqlDbType dbType)
        {
            NpgsqlParameter p = NpgSqlCommandUtils.GetParam(name, isNullable, dbType, ParameterDirection.Input);

            this.cmd.Parameters.Add(p);
            return(p);
        }
Пример #2
0
        public void AddNullInParam(string name, NpgsqlDbType dbType)
        {
            NpgsqlParameter p = NpgSqlCommandUtils.GetParam(name, true, dbType, ParameterDirection.Input);

            p.Value = DBNull.Value;
            this.cmd.Parameters.Add(p);
        }
Пример #3
0
        public static NpgsqlCon Create(string connectionString, string schema)
        {
            try
            {
                if (string.IsNullOrEmpty(connectionString) || string.IsNullOrEmpty(schema))
                {
                    return(null);
                }
                if (!NpgSqlCommandUtils.TestConnection(connectionString))
                {
                    return(null);
                }
            }
#pragma warning disable 0168
            catch (Exception e)
            {
                return(null);
            }
#pragma warning restore 0168
            return(new NpgsqlCon(connectionString, schema));
        }
Пример #4
0
 public static void PrepareCommand(NpgsqlCommand cmd, NpgsqlParameterCollection cmdParms)
 {
     if (cmdParms != null)
     {
         bool hasRet = false;
         if (cmd.CommandType != CommandType.StoredProcedure)
             hasRet = true;
         NpgsqlParameter p2;
         foreach (NpgsqlParameter parm in cmdParms)
         {
             if (parm != null)
             {
                 if (parm.Direction == ParameterDirection.ReturnValue)
                     hasRet = true;
                 p2 = parm.Clone();
                 cmd.Parameters.Add(p2);
             }
         }
         if (!hasRet)
             cmd.Parameters.Add(NpgSqlCommandUtils.GetParam("retVal", true, NpgsqlDbType.Integer, ParameterDirection.ReturnValue));
     }
 }
Пример #5
0
        public void AddOutParam(string name, bool isNullable, NpgsqlDbType dbType)
        {
            NpgsqlParameter p = NpgSqlCommandUtils.GetParam(name, isNullable, dbType, ParameterDirection.Output);

            this.cmd.Parameters.Add(p);
        }
Пример #6
0
 public static NpgsqlParameter GetNullInParam(string name, NpgsqlDbType dbType)
 {
     NpgsqlParameter p = NpgSqlCommandUtils.GetParam(name, true, dbType, ParameterDirection.Input);
     p.Value = DBNull.Value;
     return p;
 }
Пример #7
0
 public static NpgsqlParameter GetOutParam(string name, bool isNullable, NpgsqlDbType dbType)
 {
     return NpgSqlCommandUtils.GetParam(name, isNullable, dbType, ParameterDirection.Output);
 }