本文整理汇总了C#中MySql.Data.MySqlClient.MySqlField类的典型用法代码示例。如果您正苦于以下问题:C# MySqlField类的具体用法?C# MySqlField怎么用?C# MySqlField使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MySqlField类属于MySql.Data.MySqlClient命名空间,在下文中一共展示了MySqlField类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetColumnData
private void GetColumnData(MySqlField field)
{
stream.Encoding = Encoding;
packet = stream.ReadPacket();
field.Encoding = Encoding;
field.CatalogName = packet.ReadLenString();
field.DatabaseName = packet.ReadLenString();
field.TableName = packet.ReadLenString();
field.RealTableName = packet.ReadLenString();
field.ColumnName = packet.ReadLenString();
field.OriginalColumnName = packet.ReadLenString();
packet.ReadByte();
field.CharacterSetIndex = packet.ReadInteger(2);
field.ColumnLength = packet.ReadInteger(4);
MySqlDbType type = (MySqlDbType)packet.ReadByte();
ColumnFlags colFlags;
if ((connectionFlags & ClientFlags.LONG_FLAG) != 0)
colFlags = (ColumnFlags)packet.ReadInteger(2);
else
colFlags = (ColumnFlags)packet.ReadByte();
field.Scale = (byte)packet.ReadByte();
if (packet.HasMoreData)
{
packet.ReadInteger(2); // reserved
}
if (type == MySqlDbType.Decimal || type == MySqlDbType.NewDecimal)
{
field.Precision = (byte)(field.ColumnLength - 2);
if ((colFlags & ColumnFlags.UNSIGNED) != 0)
field.Precision++;
}
field.SetTypeAndFlags(type, colFlags);
}
示例2: PrepareStatement
public int PrepareStatement(string sql, ref MySqlField[] parameters)
{
//TODO: check this
//ClearFetchedRow();
packet.Length = sql.Length * 4 + 5;
byte[] buffer = packet.Buffer;
int len = Encoding.GetBytes(sql, 0, sql.Length, packet.Buffer, 5);
packet.Position = len + 5;
buffer[4] = (byte)DBCmd.PREPARE;
ExecutePacket(packet);
packet = stream.ReadPacket();
int marker = packet.ReadByte();
if (marker != 0)
throw new MySqlException("Expected prepared statement marker");
int statementId = packet.ReadInteger(4);
int numCols = packet.ReadInteger(2);
int numParams = packet.ReadInteger(2);
//TODO: find out what this is needed for
packet.ReadInteger(3);
if (numParams > 0)
{
parameters = owner.GetColumns(numParams);
// we set the encoding for each parameter back to our connection encoding
// since we can't trust what is coming back from the server
for (int i = 0; i < parameters.Length; i++)
parameters[i].Encoding = Encoding;
}
if (numCols > 0)
{
while (numCols-- > 0)
{
packet = stream.ReadPacket();
//TODO: handle streaming packets
}
ReadEOF();
}
return statementId;
}
示例3: ReadColumnValue
public IMySqlValue ReadColumnValue(int index, MySqlField field, IMySqlValue valObject)
{
long length = -1;
bool isNull;
if (nullMap != null)
isNull = nullMap[index + 2];
else
{
length = packet.ReadFieldLength();
isNull = length == -1;
}
packet.Encoding = field.Encoding;
packet.Version = version;
return valObject.ReadValue(packet, length, isNull);
}
示例4: GetColumnsData
public void GetColumnsData(MySqlField[] columns)
{
for (int i = 0; i < columns.Length; i++)
GetColumnData(columns[i]);
ReadEOF();
}
示例5: PrepareStatement
public virtual int PrepareStatement(string sql, ref MySqlField[] parameters)
{
return handler.PrepareStatement(sql, ref parameters);
}
示例6: ReadColumnValue
public IMySqlValue ReadColumnValue(int index, MySqlField field, IMySqlValue value)
{
return handler.ReadColumnValue(index, field, value);
}
示例7: ReadColumnValue
public abstract IMySqlValue ReadColumnValue(int index, MySqlField field, IMySqlValue value);
示例8: GetColumns
public MySqlField[] GetColumns(int count)
{
MySqlField[] fields = new MySqlField[count];
for (int i = 0; i < count; i++)
fields[i] = new MySqlField(this);
handler.GetColumnsData(fields);
return fields;
}
示例9: PrepareStatement
public override int PrepareStatement(string sql, ref MySqlField[] parameters)
{
int statementId = base.PrepareStatement(sql, ref parameters);
MySqlTrace.TraceEvent(TraceEventType.Information, MySqlTraceEventType.StatementPrepared,
Resources.TraceStatementPrepared, driverId, sql, statementId);
return statementId;
}
示例10: PrepareStatement
public abstract int PrepareStatement(string sql, ref MySqlField[] parameters);
示例11: PrepareStatement
public override int PrepareStatement(string sql, ref MySqlField[] parameters)
{
//TODO: check this
//ClearFetchedRow();
byte[] bytes = encoding.GetBytes(sql);
ExecuteCommand(DBCmd.PREPARE, bytes, bytes.Length);
stream.OpenPacket();
int marker = stream.ReadByte();
if (marker != 0)
throw new MySqlException("Expected prepared statement marker");
int statementId = stream.ReadInteger(4);
int numCols = stream.ReadInteger(2);
int numParams = stream.ReadInteger(2);
//TODO: find out what this is needed for
stream.ReadInteger(3);
if (numParams > 0)
{
parameters = ReadColumnMetadata(numParams);
// we set the encoding for each parameter back to our connection encoding
// since we can't trust what is coming back from the server
for (int i = 0; i < parameters.Length; i++)
parameters[i].Encoding = encoding;
}
if (numCols > 0)
{
while (numCols-- > 0)
{
stream.OpenPacket();
stream.SkipPacket();
}
ReadEOF();
}
return statementId;
}
示例12: GetFieldMetaData41
private MySqlField GetFieldMetaData41()
{
MySqlField field = new MySqlField(connection);
stream.OpenPacket();
field.Encoding = encoding;
field.CatalogName = stream.ReadLenString();
field.DatabaseName = stream.ReadLenString();
field.TableName = stream.ReadLenString();
field.RealTableName = stream.ReadLenString();
field.ColumnName = stream.ReadLenString();
field.OriginalColumnName = stream.ReadLenString();
stream.ReadByte();
field.CharacterSetIndex = stream.ReadInteger(2);
field.ColumnLength = stream.ReadInteger(4);
MySqlDbType type = (MySqlDbType) stream.ReadByte();
ColumnFlags colFlags;
if ((Flags & ClientFlags.LONG_FLAG) != 0)
colFlags = (ColumnFlags) stream.ReadInteger(2);
else
colFlags = (ColumnFlags) stream.ReadByte();
field.SetTypeAndFlags(type, colFlags);
field.Scale = (byte) stream.ReadByte();
if (stream.HasMoreData)
{
stream.ReadInteger(2); // reserved
}
if (charSets != null && field.CharacterSetIndex != -1)
{
CharacterSet cs = CharSetMap.GetChararcterSet(Version, (string) charSets[field.CharacterSetIndex]);
field.MaxLength = cs.byteCount;
field.Encoding = CharSetMap.GetEncoding(version, (string) charSets[field.CharacterSetIndex]);
}
return field;
}
示例13: GetFieldMetaData
private MySqlField GetFieldMetaData()
{
MySqlField field;
if (version.isAtLeast(4, 1, 0))
field = GetFieldMetaData41();
else
{
stream.OpenPacket();
field = new MySqlField(connection);
field.Encoding = encoding;
field.TableName = stream.ReadLenString();
field.ColumnName = stream.ReadLenString();
field.ColumnLength = stream.ReadNBytes();
MySqlDbType type = (MySqlDbType) stream.ReadNBytes();
stream.ReadByte();
ColumnFlags colFlags;
if ((Flags & ClientFlags.LONG_FLAG) != 0)
colFlags = (ColumnFlags) stream.ReadInteger(2);
else
colFlags = (ColumnFlags) stream.ReadByte();
field.SetTypeAndFlags(type, colFlags);
field.Scale = (byte) stream.ReadByte();
if (!version.isAtLeast(3, 23, 15) && version.isAtLeast(3, 23, 0))
field.Scale++;
}
return field;
}
示例14: ReadColumnMetadata
public override MySqlField[] ReadColumnMetadata(int count)
{
MySqlField[] fields = new MySqlField[count];
for (int i = 0; i < count; i++)
fields[i] = GetFieldMetaData();
ReadEOF();
return fields;
}
示例15: ReadColumnValue
public override IMySqlValue ReadColumnValue(int index, MySqlField field, IMySqlValue valObject)
{
long length = -1;
bool isNull;
if (nullMap != null)
isNull = nullMap[index + 2];
else
{
length = stream.ReadFieldLength();
isNull = length == -1;
}
stream.Encoding = field.Encoding;
return valObject.ReadValue(stream, length, isNull);
}