Esempio n. 1
0
		public static object ExecuteScalar(MySqlConnection connection, string commandText, params MySqlParameter[] commandParameters) {
			MySqlCommand command = new MySqlCommand();
			command.Connection = connection;
			command.CommandText = commandText;
			command.CommandType = CommandType.Text;
			if (commandParameters != null) {
				foreach (MySqlParameter parameter in commandParameters) {
					command.Parameters.Add(parameter);
				}
			}
			object obj2 = command.ExecuteScalar();
			command.Parameters.Clear();
			return obj2;
		}
Esempio n. 2
0
		private string GetSqlMode() {
			MySqlCommand command = new MySqlCommand("SELECT @@SQL_MODE", this.connection);
			return command.ExecuteScalar().ToString();
		}
Esempio n. 3
0
		internal string GetCommandTextForBatching() {
			if (this.batchableCommandText == null) {
				if (string.Compare(this.CommandText.Substring(0, 6), "INSERT", true) == 0) {
					MySqlCommand command = new MySqlCommand("SELECT @@sql_mode", this.Connection);
					string str = command.ExecuteScalar().ToString().ToLower(CultureInfo.InvariantCulture);
					SqlTokenizer tokenizer = new SqlTokenizer(this.CommandText);
					tokenizer.AnsiQuotes = str.IndexOf("ansi_quotes") != -1;
					tokenizer.BackslashEscapes = str.IndexOf("no_backslash_escapes") == -1;
					for (string str2 = tokenizer.NextToken().ToLower(CultureInfo.InvariantCulture); str2 != null; str2 = tokenizer.NextToken()) {
						if ((str2.ToLower(CultureInfo.InvariantCulture) == "values") && !tokenizer.Quoted) {
							str2 = tokenizer.NextToken();
							while ((str2 != null) && (str2 != ")")) {
								this.batchableCommandText = this.batchableCommandText + str2;
								str2 = tokenizer.NextToken();
							}
							if (str2 != null) {
								this.batchableCommandText = this.batchableCommandText + str2;
							}
							str2 = tokenizer.NextToken();
							if ((str2 != null) && ((str2 == ",") || (str2.ToLower(CultureInfo.InvariantCulture) == "on"))) {
								this.batchableCommandText = null;
								break;
							}
						}
					}
				}
				if (this.batchableCommandText == null) {
					this.batchableCommandText = this.CommandText;
				}
			}
			return this.batchableCommandText;
		}
Esempio n. 4
0
		internal string CurrentDatabase() {
			if ((this.Database != null) && (this.Database.Length > 0)) {
				return this.Database;
			}
			MySqlCommand command = new MySqlCommand("SELECT database()", this);
			return command.ExecuteScalar().ToString();
		}