public MySqlCommand() { this.designTimeVisible = true; this.cmdType = System.Data.CommandType.Text; this.parameters = new MySqlParameterCollection(this); this.updatedRowSource = UpdateRowSource.Both; this.cursorPageSize = 0; this.cmdText = string.Empty; this.timedOut = false; }
private bool SerializeParameter(MySqlParameterCollection parameters, MySqlStream stream, string parmName) { MySqlParameter parameterFlexible = parameters.GetParameterFlexible(parmName, false); if (parameterFlexible == null) { if (!parmName.StartsWith("@") || !this.ShouldIgnoreMissingParameter(parmName)) { throw new MySqlException(string.Format(Resources.ParameterMustBeDefined, parmName)); } return(false); } parameterFlexible.Serialize(stream, false); return(true); }
protected virtual void BindParameters() { MySqlParameterCollection parameters = this.command.Parameters; int num = 0; do { this.InternalBindParameters(this.ResolvedCommandText, parameters, null); if (this.command.Batch != null) { while (num < this.command.Batch.Count) { MySqlCommand command = this.command.Batch[num++]; MySqlStream stream = (MySqlStream)this.buffers[this.buffers.Count - 1]; long num2 = command.EstimatedSize(); if ((stream.InternalBuffer.Length + num2) > this.Connection.driver.MaxPacketSize) { parameters = command.Parameters; break; } this.buffers.RemoveAt(this.buffers.Count - 1); long length = stream.InternalBuffer.Length; string batchableCommandText = command.BatchableCommandText; if (batchableCommandText.StartsWith("(")) { stream.WriteStringNoNull(", "); } else { stream.WriteStringNoNull("; "); } this.InternalBindParameters(batchableCommandText, command.Parameters, stream); if (stream.InternalBuffer.Length > this.Connection.driver.MaxPacketSize) { stream.InternalBuffer.SetLength(length); parameters = command.Parameters; break; } } } else { return; } }while (num != this.command.Batch.Count); }
private void InternalBindParameters(string sql, MySqlParameterCollection parameters, MySqlStream stream) { ArrayList list = this.TokenizeSql(sql); if (stream == null) { stream = new MySqlStream(this.Driver.Encoding); stream.Version = this.Driver.Version; } string str = (string)list[list.Count - 1]; if (str != ";") { list.Add(";"); } foreach (string str2 in list) { if (str2.Trim().Length == 0) { continue; } if (str2 == ";") { this.buffers.Add(stream); stream = new MySqlStream(this.Driver.Encoding); continue; } if (((str2.Length < 2) || (((str2[0] != '@') || (str2[1] == '@')) && (str2[0] != '?'))) || !this.SerializeParameter(parameters, stream, str2)) { stream.WriteStringNoNull(str2); } } }
private bool SerializeParameter(MySqlParameterCollection parameters, MySqlStream stream, string parmName) { MySqlParameter parameterFlexible = parameters.GetParameterFlexible(parmName, false); if (parameterFlexible == null) { if (!parmName.StartsWith("@") || !this.ShouldIgnoreMissingParameter(parmName)) { throw new MySqlException(string.Format(Resources.ParameterMustBeDefined, parmName)); } return false; } parameterFlexible.Serialize(stream, false); return true; }