zoukankan      html  css  js  c++  java
  • 连接sql

    protected string connstr;
      protected SqlConnection conn;
      protected SqlCommand comm;
      protected SqlDataAdapter da;
    protected DataSet ds;

      private void InitDataSource()
      {
       connstr = "Server=.;DataBase=pubs;uid=sa;pwd=sql";
       conn = new SqlConnection(connstr);
       comm = new SqlCommand();
       comm.Connection = conn;
       comm.CommandText = "select * from authors where au_id=@au_id";
       comm.Parameters.Add("@au_id",SqlDbType.VarChar,11,"au_id");     
       comm.Parameters[0].Value = this.Request.QueryString["au_id"];
       comm.CommandType = CommandType.Text;

       da = new SqlDataAdapter();
       da.SelectCommand = comm;

       ds = new DataSet();

       da.Fill(ds);
      }

    void BindDataSource()
      {
       DataRow dr = ds.Tables[0].Rows[0];
       this.TextBox1.Text =dr[0] .ToString();
       this.TextBox2.Text =dr[1].ToString();
       this.TextBox3.Text = dr[2].ToString();
       this.TextBox4.Text =dr[3].ToString();
       this.TextBox5.Text = dr[5].ToString();

      }


    private void InitializeComponent()
      {   
       this.Load += new System.EventHandler(this.Page_Load);

      }

  • 相关阅读:
    POJ 3126 Prime Path
    POJ 2429 GCD & LCM Inverse
    POJ 2395 Out of Hay
    【Codeforces 105D】 Bag of mice
    【POJ 3071】 Football
    【POJ 2096】 Collecting Bugs
    【CQOI 2009】 余数之和
    【Codeforces 258E】 Devu and Flowers
    【SDOI 2010】 古代猪文
    【BZOJ 2982】 combination
  • 原文地址:https://www.cnblogs.com/puke/p/756599.html
Copyright © 2011-2022 走看看