예제 #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);
 }