zoukankan      html  css  js  c++  java
  • 一段常用的Page_Load事件 (如果有更好的希望大家留言)

    protected void Page_Load(object sender, EventArgs e)
      {
       SqlConnection myConnection = new SqlConnection("server=Localhost;database=pubs;uid=sa;pwd=;");//创建SQL连接
       SqlCommand myCommand = new SqlCommand("SELECT title, price FROM Titles WHERE price > 0", myConnection);//创建SQL命令
      
       try
       {
        myConnection.Open();//打开数据库连接
        MyGrid.DataSource = myCommand.ExecuteReader();//指定 DataGrid 的数据源
        MyGrid.DataBind();//绑定数据到 DataGrid
        myConnection.Close();//关闭数据连接
       }
       catch(Exception ex)
       {
        //捕获错误
        HttpContext.Current.Response.Write(ex.ToString());
       }
      } 
  • 相关阅读:
    shell编程
    git
    Flask-SQLAlchemy
    pipreqs
    命令行操作flask
    SQLAlchemy中scoped_session实现线程安全
    打印信息
    键盘事件
    安卓手机APP压力monkey测试
    手机APP功能测试经验分享2016.06.06
  • 原文地址:https://www.cnblogs.com/angelfeather/p/1225931.html
Copyright © 2011-2022 走看看