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);

      }

  • 相关阅读:
    Oracle修改字段类型
    JS解析JSON字符串
    C#Json转DataTable
    解决前台和后台传值出现中文乱码
    Oracle 存储过程简单语法
    EasyUI 冻结列
    EasyUI 数据网格行过滤
    windows计划任务
    C#日志文件
    bat 读取 ini 配置文件
  • 原文地址:https://www.cnblogs.com/puke/p/756599.html
Copyright © 2011-2022 走看看