1. Hashtable 数据遍历的几种方式

      ---Hashtable 在集合中称为键值对,它的每一个元素的类型是 DictionaryEntry,由于Hashtable对象的键和值都是Object类型,决定了它可以放任何类型的数据

  1.  Hashtable ht = new Hashtable();
    ht.Add("", person1);
    ht.Add("", person2);
    ht.Add("", person3);
    ht.Add("", person4);
    ht.Add("", person5);
    Console.WriteLine("请输入你的查询的用户名:");
    string strName = Console.ReadLine();
    //第一种方法
    foreach (string item in ht.Keys)
    {
    Person p = (Person)ht[item];
    if (strName == p.Name)
    {
    Console.WriteLine("查询后的结果是:" + p.Name + "\t" + p.Email + "\t" + p.Age);
    }
    } //第二种方法
    foreach (Person item in ht.Values)
    {
    if (item.Name == strName)
    {
    Console.WriteLine("查询后的结果是:" + item.Name + "\t" + item.Email + "\t" + item.Age);
    } }
    //第三种方法
    foreach (DictionaryEntry item in ht)
    {
    if (strName == ((Person)item.Value).Name)
    {
    Console.WriteLine("查询后的结果是:" + ((Person)item.Value).Name + "\t" + ((Person)item.Value).Email + "\t" + ((Person)item.Value).Age);
    }
    } //第四种方法
    IDictionaryEnumerator id = ht.GetEnumerator();
    while (id.MoveNext())
    {
    Person p = (Person)ht[id.Key];
    if (p.Name == strName)
    {
    Console.WriteLine("查询后的结果是:" + p.Name + "\t" + p.Email + "\t" + p.Age);
    }
    }
  2. mysql存储过程游标的使用范例
    使用table 记录CURSOR FETCH 出来的值
    
    CREATE PROCEDURE processorders()
    BEGIN DECLARE o INT;
    DECLARE done BOOLEAN DEFAULT ;
    DECLARE t DECIMAL(,); DECLARE ordernumbers CURSOR
    FOR
    SELECT order_num FROM orders; -- Declare continue handler
    DECLARE CONTINUE HANDLER FOR SQLSTATE '' SET done = ;
    -- SQLSTATE '' 是一个未找到条件,当没有更多行可读的时候设置 done = 然后退出 -- 创建table
    CREATE TABLE IF NOT EXISTS ordertotals(
    order_num INT, total DECIAML(,)
    ); OPEN ordernumbers;
    REPEAT FETCH ordernumbers INTO o;
    CALL ordertotal(o,,t); -- 调用过程 -- 插入table
    INSERT INTO ordertotals(order_num, total)
    VALUES(o,t); UNTIL done END REPEAT; CLOSE ordernumbers;
    END;
  3. 事务处理( transaction processing) 可以用来维护数据库的完整性,它保证成批的MySQL操作要么完全执行,要么不执行。
    几个术语:
    事务:transaction 指一组SQL语句
    回退:rollback 指撤销指定SQL语句过程
    提交:commit 指将为存储的SQL语句结果写入数据库表
    保留点:savepoint 指事务处理中设置的临时占位符,你可以对它发布退回
    -------------
    SELECT * FROM ordertotals;
    START TRANSACTION;
    DELETE FROM ordertotals; --删除表
    SELECT * FROM ordertotals; -- 确认删除
    ROLLBACK; -- 回滚
    SELECT * FROM ordertotal; -- 再次显示 --------------commit
    一般的MySQL语句都是直接针对数据库表进行操作,进行隐含的提交,即提交操作是自动执行的。
    在 事务处理中,提交不会隐含执行,需要使用COMMIT语句。
    START TRANSACTION;
    DELETE FROM orderitems WHERE order_num = ;
    DELETE FROM orders WHERE order_num = ;
    COMMIT;
  4. MySql与SqlServer的一些常用SQL语句用法的差别
  5. 
    本文将主要列出MySql与SqlServer不同的地方,且以常用的存储过程的相关内容为主。
    
    . 标识符限定符
    
    SqlServer    []
    MySql ``
    . 字符串相加 SqlServer 直接用 +
    MySql concat()
    . isnull() SqlServer isnull()
    MySql ifnull()
    注意:MySql也有isnull()函数,但意义不一样
    . getdate() SqlServer getdate()
    MySql now()
    . newid() SqlServer newid()
    MySql uuid()
    . @@ROWCOUNT SqlServer @@ROWCOUNT
    MySql row_count()
    注意:MySql的这个函数仅对于update, insert, delete有效
    . SCOPE_IDENTITY() SqlServer SCOPE_IDENTITY()
    MySql last_insert_id()
    . if ... else ... SqlServer
    IF Boolean_expression
    { sql_statement | statement_block }
    [ ELSE
    { sql_statement | statement_block } ] -- 若要定义语句块,请使用控制流关键字 BEGIN 和 END。
    MySql
    IF search_condition THEN statement_list
    [ELSEIF search_condition THEN statement_list] ...
    [ELSE statement_list]
    END IF
    注意:对于MySql来说,then, end if是必须的。类似的还有其它的流程控制语句,这里就不一一列出。 . declare 其实,SqlServer和MySql都有这个语句,用于定义变量,但差别在于:在MySql中,DECLARE仅被用在BEGIN ... END复合语句里,并且必须在复合语句的开头,在任何其它语句之前。这个要求在写游标时,会感觉很BT. . 游标的写法 SqlServer
    declare @tempShoppingCart table (ProductId int, Quantity int)
    insert into @tempShoppingCart (ProductId, Quantity)
    select ProductId, Quantity from ShoppingCart where UserGuid = @UserGuid declare @productId int
    declare @quantity int
    declare tempCartCursor cursor for
    select ProductId, Quantity from @tempShoppingCart open tempCartCursor
    fetch next from tempCartCursor into @productId, @quantity
    while @@FETCH_STATUS =
    begin
    update Product set SellCount = SellCount + @quantity where productId = @productId fetch next from tempCartCursor into @productId, @quantity
    end close tempCartCursor
    deallocate tempCartCursor
    MySql
    declare m_done int default ;
    declare m_sectionId int;
    declare m_newsId int; declare _cursor_SN cursor for select sectionid, newsid from _temp_SN;
    declare continue handler for not found set m_done = ; create temporary table _temp_SN
    select sectionid, newsid from SectionNews group by sectionid, newsid having count(*) > ; open _cursor_SN;
    while( m_done = ) do
    fetch _cursor_SN into m_sectionId, m_newsId; if( m_done = ) then
    -- 具体的处理逻辑
    end if;
    end while;
    close _cursor_SN;
    drop table _temp_SN;
    注意:为了提高性能,通常在表变量上打开游标,不要直接在数据表上打开游标。 . 分页的处理 SqlServer
    create procedure GetProductByCategoryId(
    @CategoryID int,
    @PageIndex int = ,
    @PageSize int = ,
    @TotalRecords int output
    )
    as
    begin declare @ResultTable table
    (
    RowIndex int,
    ProductID int,
    ProductName nvarchar(),
    CategoryID int,
    Unit nvarchar(),
    UnitPrice money,
    Quantity int
    ); insert into @ResultTable
    select row_number() over (order by ProductID asc) as RowIndex,
    p.ProductID, p.ProductName, p.CategoryID, p.Unit, p.UnitPrice, p.Quantity
    from Products as p
    where CategoryID = @CategoryID; select @TotalRecords = count(*) from @ResultTable; select *
    from @ResultTable
    where RowIndex > (@PageSize * @PageIndex) and RowIndex <= (@PageSize * (@PageIndex+)); end;
    当然,SqlServer中并不只有这一种写法,只是这种写法是比较常见而已。 MySql
    create procedure GetProductsByCategoryId(
    in _categoryId int,
    in _pageIndex int,
    in _pageSize int,
    out _totalRecCount int
    )
    begin set @categoryId = _categoryId;
    set @startRow = _pageIndex * _pageSize;
    set @pageSize = _pageSize; prepare PageSql from
    'select sql_calc_found_rows * from product where categoryId = ? order by ProductId desc limit ?, ?';
    execute PageSql using @categoryId, @startRow, @pageSize;
    deallocate prepare PageSql;
    set _totalRecCount = found_rows(); end
    MySql与SqlServer的差别实在太多,以上只是列出了我认为经常在写存储过程中会遇到的一些具体的差别之处
  6. winform程序动态加载控件,总是窗体先出现,防止窗体上的控件闪一下,在主窗体里加入如下代码:
             /// <summary>
    /// 防止窗体闪烁
    /// </summary>
    protected override CreateParams CreateParams
    {
    get
    {
    CreateParams cp = base.CreateParams;
    cp.ExStyle |= 0x02000000;
    return cp;
    }
    }

winform学习笔记02的更多相关文章

  1. 软件测试之loadrunner学习笔记-02集合点

    loadrunner学习笔记-02集合点 集合点函数可以帮助我们生成有效可控的并发操作.虽然在Controller中多用户负载的Vuser是一起开始运行脚本的,但是由于计算机的串行处理机制,脚本的运行 ...

  2. 机器学习实战(Machine Learning in Action)学习笔记————02.k-邻近算法(KNN)

    机器学习实战(Machine Learning in Action)学习笔记————02.k-邻近算法(KNN) 关键字:邻近算法(kNN: k Nearest Neighbors).python.源 ...

  3. OpenCV 学习笔记 02 使用opencv处理图像

    1 不同色彩空间的转换 opencv 中有数百种关于不同色彩空间的转换方法,但常用的有三种色彩空间:灰度.BRG.HSV(Hue-Saturation-Value) 灰度 - 灰度色彩空间是通过去除彩 ...

  4. SaToken学习笔记-02

    SaToken学习笔记-02 如果排版有问题,请点击:传送门 常用的登录有关的方法 - StpUtil.logout() 作用为:当前会话注销登录 调用此方法,其实做了哪些操作呢,我们来一起看一下源码 ...

  5. Redis:学习笔记-02

    Redis:学习笔记-02 该部分内容,参考了 bilibili 上讲解 Redis 中,观看数最多的课程 Redis最新超详细版教程通俗易懂,来自 UP主 遇见狂神说 4. 事物 Redis 事务本 ...

  6. OGG学习笔记02

    实验环境:源端:192.168.1.30,Oracle 10.2.0.5 单实例目标端:192.168.1.31,Oracle 10.2.0.5 单实例 1.模拟源数据库业务持续运行 2.配置OGG前 ...

  7. 《Master Bitcoin》学习笔记02——比特币的交易模型

    比特币的交易模型 模型基本描述 前面一篇学习笔记01提到了一个交易模型(第三章的内容),在第五章中,除了对这个模型做个详细介绍之外,其实和我上一篇理解的交易模型差不多,一个交易包含输入与输出,比特币是 ...

  8. [Golang学习笔记] 02 命令源码文件

    源码文件的三种类型: 命令源文件:可以直接运行的程序,可以不编译而使用命令“go run”启动.执行. 库源码文件 测试源码文件 面试题:命令源码文件的用途是什么,怎样编写它? 典型回答: 命令源码文 ...

  9. [原创]java WEB学习笔记02:javaWeb开发的目录结构

    本博客为原创:综合 尚硅谷(http://www.atguigu.com)的系统教程(深表感谢)和 网络上的现有资源(博客,文档,图书等),资源的出处我会标明 本博客的目的:①总结自己的学习过程,相当 ...

随机推荐

  1. Netsuite Formula > Oracle函数列表速查(PL/SQL单行函数和组函数详解).txt

    PL/SQL单行函数和组函数详解 函数是一种有零个或多个参数并且有一个返回值的程序.在SQL中Oracle内建了一系列函数,这些函数都可被称为SQL或PL/SQL语句,函数主要分为两大类: 单行函数 ...

  2. java full gc

    转自:http://blog.sina.com.cn/s/blog_7a351012010163a1.html

  3. position absolute 绝对定位 设置问题

     今天在做布局的时候,用到了绝对定位, 父级元素相对定位,子元素两个,一个元素正常文档流布局并且在前面,另一个元素绝对定位排在后面,但设置了好久,绝对定位的子元素都不会覆盖其上面的兄弟元素,最后,不知 ...

  4. js跨域_jsonP

    $.ajax("url", type:"get", dataType:"jsonp", jsonp:"callback" ...

  5. [SoapUI] Groovy在SoapUI里获取Text文本第一行数据

    // get external txt file datadef groovyUtils =new com.eviware.soapui.support.GroovyUtils(context)def ...

  6. memset函数

    函数介绍 void *memset(void *s, int ch, size_t n); 函数解释:将s中前n个字节 (typedef unsigned int size_t )用 ch 替换并返回 ...

  7. Java中的JDK动态代理

    所谓代理,其实就是相当于一个中间人,当客户端需要服务端的服务时,不是客户直接去找服务,而是客户先去找代理,告诉代理需要什么服务,然后代理再去服务端找服务,最后将结果返回给客户. 在日常生活中,就拿买火 ...

  8. 利用Spring中同名Bean相互覆盖的特性,定制平台的类内容。

    欢迎和大家交流技术相关问题: 邮箱: jiangxinnju@163.com 博客园地址: http://www.cnblogs.com/jiangxinnju GitHub地址: https://g ...

  9. [WPF]ComboBox.Items为空时,点击不显示下拉列表

    ComboBox.Items为空时,点击后会显示空下拉列表: ComboBox点击显示下拉列表,大概原理为: ComboBox存在ToggleButton控件,默认ToggleButton.IsChe ...

  10. Appium之python API

    webdriver contexts(self) 说明:返回多个会话内容 使用:driver.contexts current_context(self) 说明:返回单个会话的内容 使用:driver ...