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());
       }
      } 
  • 相关阅读:
    10.11-10.16
    10.8-10.10
    9.26-28
    9.29css继承属性
    表单的学习
    排版
    css补充
    今天学的新内容
    新内容
    文本样式的修改
  • 原文地址:https://www.cnblogs.com/angelfeather/p/1225931.html
Copyright © 2011-2022 走看看