예제 #1
0
        static string CreateMessage(OdbcErrorCollection errors)
        {
            StringBuilder sb = new StringBuilder();

            for (int i = 0; i < errors.Count; i++)
            {
                if (i > 0)
                {
                    sb.Append(Environment.NewLine);
                }
                OdbcError error = errors [i];
                sb.AppendFormat("ERROR [{0}] {1}", error.SQLState,
                                error.Message);
            }
            return(sb.ToString());
        }
예제 #2
0
 internal void Add(OdbcError error)
 {
     _items.Add(error);
 }
 public void CopyTo(OdbcError[] array, int i)
 {
     this._items.CopyTo(array, i);
 }
		internal OdbcException(OdbcError Error) : base (Error.Message)
		{
			odbcErrors = new OdbcErrorCollection ();
			odbcErrors.Add (Error);
		}
 internal void Add(OdbcError error)
 {
     _items.Add((object)error);
 }
 internal void Add(OdbcError error)
 {
     this._items.Add(error);
 }
예제 #7
0
		internal void Add (OdbcError error)
		{
			_items.Add ((object) error);
		}
예제 #8
0
		public void CopyTo (OdbcError [] array, int i)
		{
			if (array == null)
				throw new ArgumentNullException ("array");

			if ((i < array.GetLowerBound (0)) || (i > array.GetUpperBound (0)))
				throw new ArgumentOutOfRangeException ("index");
			((OdbcError[]) (_items.ToArray ())).CopyTo (array, i);
		}
		long GetBytes (int ordinal, long dataIndex, byte[] buffer, int bufferIndex, int length)
		{
                        OdbcReturn ret = OdbcReturn.Error;
                        bool copyBuffer = false;
                        int returnVal = 0, outsize = 0;
                        byte [] tbuff = new byte [length+1];

                        length = buffer == null ? 0 : length;
                        ret=libodbc.SQLGetData (hstmt, (ushort) (ordinal+1), SQL_C_TYPE.BINARY, tbuff, length, 
                                        ref outsize);

                        if (ret == OdbcReturn.NoData)
                                return 0;

                        if ( (ret != OdbcReturn.Success) && (ret != OdbcReturn.SuccessWithInfo)) 
                                throw new OdbcException (new OdbcError ("SQLGetData", OdbcHandleType.Stmt, hstmt));

			OdbcError odbcErr = null;
			if ( (ret == OdbcReturn.SuccessWithInfo))
				odbcErr = new OdbcError ("SQLGetData", OdbcHandleType.Stmt, hstmt);

                        if (buffer == null)
                                return outsize; //if buffer is null,return length of the field
                        
                        if (ret == OdbcReturn.SuccessWithInfo) {
                                if (outsize == (int) OdbcLengthIndicator.NoTotal)
                                        copyBuffer = true;
                                else if (outsize == (int) OdbcLengthIndicator.NullData) {
                                        copyBuffer = false;
                                        returnVal = -1;
                                } else {
                                        string sqlstate = odbcErr.SQLState;
                                        //SQLState: String Data, Right truncated
                                        if (sqlstate != libodbc.SQLSTATE_RIGHT_TRUNC) 
                                                throw new OdbcException ( odbcErr);
                                        copyBuffer = true;
                                }
                        } else {
                                copyBuffer = outsize == -1 ? false : true;
                                returnVal = outsize;
                        }

                        if (copyBuffer) {
                                int i = 0;
                                while (tbuff [i] != libodbc.C_NULL) {
                                        buffer [bufferIndex + i] = tbuff [i];
                                        i++;
                                }
                                returnVal = i;
                        }
                        return returnVal;
		}
예제 #10
0
        long GetBytes(int ordinal, long dataIndex, byte[] buffer, int bufferIndex, int length)
        {
            OdbcReturn ret = OdbcReturn.Error;
            bool       copyBuffer = false;
            int        returnVal = 0, outsize = 0;

            byte [] tbuff = new byte [length + 1];

            length = buffer == null ? 0 : length;
            ret    = libodbc.SQLGetData(hstmt, (ushort)(ordinal + 1), SQL_C_TYPE.BINARY, tbuff, length,
                                        ref outsize);

            if (ret == OdbcReturn.NoData)
            {
                return(0);
            }

            if ((ret != OdbcReturn.Success) && (ret != OdbcReturn.SuccessWithInfo))
            {
                throw new OdbcException(new OdbcError("SQLGetData", OdbcHandleType.Stmt, hstmt));
            }

            OdbcError odbcErr = null;

            if ((ret == OdbcReturn.SuccessWithInfo))
            {
                odbcErr = new OdbcError("SQLGetData", OdbcHandleType.Stmt, hstmt);
            }

            if (buffer == null)
            {
                return(outsize);                //if buffer is null,return length of the field
            }
            if (ret == OdbcReturn.SuccessWithInfo)
            {
                if (outsize == (int)OdbcLengthIndicator.NoTotal)
                {
                    copyBuffer = true;
                }
                else if (outsize == (int)OdbcLengthIndicator.NullData)
                {
                    copyBuffer = false;
                    returnVal  = -1;
                }
                else
                {
                    string sqlstate = odbcErr.SQLState;
                    //SQLState: String Data, Right truncated
                    if (sqlstate != libodbc.SQLSTATE_RIGHT_TRUNC)
                    {
                        throw new OdbcException(odbcErr);
                    }
                    copyBuffer = true;
                }
            }
            else
            {
                copyBuffer = outsize == -1 ? false : true;
                returnVal  = outsize;
            }

            if (copyBuffer)
            {
                int i = 0;
                while (tbuff [i] != libodbc.C_NULL)
                {
                    buffer [bufferIndex + i] = tbuff [i];
                    i++;
                }
                returnVal = i;
            }
            return(returnVal);
        }
예제 #11
0
 internal OdbcException(OdbcError Error) : base(Error.Message)
 {
     odbcErrors = new OdbcErrorCollection();
     odbcErrors.Add(Error);
 }