private OdbcColumn GetColumn (int ordinal)
{
if (cols [ordinal] == null) {
short bufsize = 255;
byte [] colname_buffer = new byte [bufsize];
string colname;
short colname_size = 0;
uint ColSize = 0;
short DecDigits = 0, Nullable = 0, dt = 0;
OdbcReturn ret = libodbc.SQLDescribeCol (hstmt, Convert.ToUInt16 (ordinal + 1),
colname_buffer, bufsize, ref colname_size, ref dt, ref ColSize,
ref DecDigits, ref Nullable);
if ((ret != OdbcReturn.Success) && (ret != OdbcReturn.SuccessWithInfo))
throw Connection.CreateOdbcException (OdbcHandleType.Stmt, hstmt);
colname = RemoveTrailingNullChar (Encoding.Unicode.GetString (colname_buffer));
OdbcColumn c = new OdbcColumn (colname, (SQL_TYPE) dt);
c.AllowDBNull = (Nullable != 0);
c.Digits = DecDigits;
if (c.IsVariableSizeType)
c.MaxLength = (int) ColSize;
cols [ordinal] = c;
}
return cols [ordinal];
}