当前位置: 首页>>代码示例>>C#>>正文


C# MySqlCommand.ExecuteScalarAsync方法代码示例

本文整理汇总了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;
                }

            }
        }
开发者ID:oscarito9410,项目名称:wpHotel,代码行数:24,代码来源:CrudUsuario.cs

示例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();
     }
 }
开发者ID:Toffer305,项目名称:icresponse2,代码行数:16,代码来源:OverviewStatus.xaml.cs

示例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;

            }
        }
开发者ID:oscarito9410,项目名称:wpHotel,代码行数:15,代码来源:ICrudHelper.cs

示例4: query

 public static async Task<object> query(string query) {
     using (var command = new MySqlCommand(query, Connection)) {
         return await command.ExecuteScalarAsync();
     }
 }
开发者ID:Hotallday,项目名称:iXat-Server,代码行数:5,代码来源:Database.cs

示例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;
 }
开发者ID:imbavirus,项目名称:TrinityCoreAdmin,代码行数:16,代码来源:MySQLConnection.cs


注:本文中的MySql.Data.MySqlClient.MySqlCommand.ExecuteScalarAsync方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。