本文整理汇总了C#中MySql.Data.MySqlClient.MySqlCommand.ExecuteScalarAsync方法的典型用法代码示例。如果您正苦于以下问题:C# MySqlCommand.ExecuteScalarAsync方法的具体用法?C# MySqlCommand.ExecuteScalarAsync怎么用?C# MySqlCommand.ExecuteScalarAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MySql.Data.MySqlClient.MySqlCommand
的用法示例。
在下文中一共展示了MySqlCommand.ExecuteScalarAsync方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: exists
public override async Task<bool> exists(object table)
{
var usuario = this.getCastUsuario(table);
using (MySqlConnection MidbConexion = new MySqlConnection(this.dbPath))
{
MidbConexion.Open();//Abrimos la conexion para realizar los siguientes pasos
// 'Declaro comando para poder realizar mis instrucciones sql
MySqlCommand micomando = new MySqlCommand { Connection = MidbConexion, CommandText = "SELECT*FROM usuario WHERE nombre=?Nom AND Password=?Pass" };
micomando.Parameters.AddWithValue("?Nom", usuario.nombre);
micomando.Parameters.AddWithValue("?Pass", usuario.password);
Console.WriteLine("NOMBRE {0}", usuario.nombre);
Console.WriteLine("Passwor {0}", usuario.password);
int numEncontrado = Convert.ToInt32(await micomando.ExecuteScalarAsync());
if (numEncontrado == 0)
{
return false;
}
else
{
return true;
}
}
}
示例2: GetInCalls
private async void GetInCalls()
{
using (MySqlConnection dbConn = new MySqlConnection("Server=" + ICResponse.Properties.Settings.Default.DBServer +
";Database=" + ICResponse.Properties.Settings.Default.DBName +
";Uid=" + ICResponse.Properties.Settings.Default.DBUser +
";Pwd=" + ICResponse.Properties.Settings.Default.DBPass + ";"))
{
dbConn.Open();
using (MySqlCommand cmd = new MySqlCommand(ICResponse.Properties.Settings.Default.GetInCallCounts, dbConn))
{
incallcount = Convert.ToInt32(await cmd.ExecuteScalarAsync());
InCallSector.Count = incallcount;
}
dbConn.Close();
}
}
示例3: isUpdate
public async Task<bool> isUpdate(String tableName, String idColumn, int idValue)
{
using (MySqlConnection MidbConexion = new MySqlConnection(this.dbPath))
{
MidbConexion.Open();
MySqlCommand miComando = new MySqlCommand()
{
Connection = MidbConexion,
CommandText = String.Format("SELECT COUNT(*) FROM {0} WHERE {1}=?id", tableName, idColumn)
};
miComando.Parameters.AddWithValue("?id", idValue);
return Convert.ToInt32(await miComando.ExecuteScalarAsync()) == 0 ? false : true;
}
}
示例4: query
public static async Task<object> query(string query) {
using (var command = new MySqlCommand(query, Connection)) {
return await command.ExecuteScalarAsync();
}
}
示例5: ExecuteScalar
public async Task<object> ExecuteScalar(MySqlCommand stmt)
{
object result = null;
if (connState == ConnectionState.Open)
{
try
{
result = await stmt.ExecuteScalarAsync();
}
catch (MySqlException e)
{
Logger.LOG_DATABASE.Error("Could not execute prepared statement " + stmt.ToString() + " as scalar. " + e.Message);
}
}
return result;
}