乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      Ado.NET/ActiveX?Data?Object.NET

       悟靜 2011-02-10

       ASP.NET是通過ADO.NET來訪問數(shù)據(jù)庫的Ado.NET/ActiveX <wbr>Data <wbr>Object.NET

      數(shù)據(jù)提供者包含4個主要組件:

      Connection:用于連接到數(shù)據(jù)庫或其它數(shù)據(jù)源。
      Command:用于在數(shù)據(jù)庫中檢索、編輯、刪除、或插入數(shù)據(jù)。
      DataReader從數(shù)據(jù)源提供數(shù)據(jù)流。這些數(shù)據(jù)只讀(不可修改),我們只能向前經(jīng)過這些數(shù)據(jù)。

      -------------------------------------------------------------------------------------

      DataReader對象沒有公用的構(gòu)造函數(shù),所以不能使用DataReader對象的構(gòu)造函數(shù)來創(chuàng)建一個DataReader對象,只能用Command對象中的ExecuteReader方法來創(chuàng)建一個DataReader對象

      ---------------------------------------------------------------------------------------
      DataAdapter:用于將數(shù)據(jù)源中的數(shù)據(jù)填充到DataSet中,并將在DataSet中數(shù)據(jù)的變化返回到數(shù)據(jù)庫中??梢詫?shù)據(jù)適配器看作是DataSet與數(shù)據(jù)庫之間的橋梁。

      DataSet :數(shù)據(jù)集,相當(dāng)于駐留在內(nèi)存中的數(shù)據(jù)庫

      使用Ado.NET實現(xiàn)以下功能:

      Ado.NET/ActiveX <wbr>Data <wbr>Object.NET

      private void Form1_Load(object sender, System.EventArgs e)
        {
         bind();
        }
              //查找用戶信息
        void bind()
        {
         SqlConnection conn=new SqlConnection("server=.;database=DBForADO;uid=sa;pwd=;");
         SqlDataAdapter sda=new SqlDataAdapter("select * from login",conn);
         DataSet ds=new DataSet();
         sda.Fill(ds,0,0,"login");
         this.dataGrid1.DataSource=ds.Tables["login"];
        }
        
        //Sql語句增加 =====SqlDataAdapter與DataSet組合
        private void button1_Click(object sender, System.EventArgs e)
        {
         SqlConnection conn=new SqlConnection("server=.;database=DBForADO;uid=sa;pwd=;");
      //   string username=this.textBox1.Text;
      //   string userpwd=this.textBox2.Text;
         SqlDataAdapter sda=new SqlDataAdapter("insert into login(uname,upwd) values('"+this.textBox1.Text+"','"+this.textBox2.Text+"')",conn);
         DataSet ds=new DataSet();
         sda.Fill(ds,0,0,"login");
         bind();
        }
        //存儲過程增加
        private void button5_Click(object sender, System.EventArgs e)
        {
         SqlConnection conn=new SqlConnection("server=.;database=DBForADO;uid=sa;pwd=;");
         SqlDataAdapter sda=new SqlDataAdapter("SqlAndProc_Login_Insert",conn);
         sda.SelectCommand.CommandType=CommandType.StoredProcedure;
         sda.SelectCommand.Parameters.Add("@name",this.textBox1.Text);
         sda.SelectCommand.Parameters.Add("@pwd",this.textBox2.Text);
         DataSet ds=new DataSet();
         sda.Fill(ds,0,0,"login");
         bind();
        }
        //Sql語句刪除=====SqlDataAdapter與DataSet組合
        private void button2_Click(object sender, System.EventArgs e)
        {
         SqlConnection conn=new SqlConnection("server=.;database=DBForADO;uid=sa;pwd=;");
         SqlDataAdapter sda=new SqlDataAdapter("delete from login where uname='"+this.textBox1.Text+"'",conn);
         DataSet ds=new DataSet();
         sda.Fill(ds,"login");
         this.dataGrid1.DataSource=ds.Tables["login"];
         bind();
        }
        //存儲過程刪除(刪除輸入的用戶名的記錄)
        private void button6_Click(object sender, System.EventArgs e)
        {
         SqlConnection conn=new SqlConnection("server=.;database=DBForADO;uid=sa;pwd=;");
         SqlDataAdapter sda=new SqlDataAdapter("SqlAndProc_Login_Del",conn);
         sda.SelectCommand.CommandType=CommandType.StoredProcedure;
         sda.SelectCommand.Parameters.Add("@name",this.textBox1.Text);
         DataSet ds=new DataSet();
         sda.Fill(ds,0,0,"login");
         bind();
        }
        //Sql語句查找=====SqlDataAdapter與DataSet組合
        private void button3_Click(object sender, System.EventArgs e)
        {
         SqlConnection conn=new SqlConnection("server=.;database=DBForADO;uid=sa;pwd=;");  
         SqlDataAdapter sda=new SqlDataAdapter("select * from login where uname='"+this.textBox1.Text+"'",conn);
         DataSet ds=new DataSet();
         sda.Fill(ds,"login");
         this.dataGrid1.DataSource=ds.Tables["login"];

        }
        //存儲過程查找
        private void button7_Click(object sender, System.EventArgs e)
          
         SqlConnection conn=new SqlConnection("server=.;database=DBForADO;uid=sa;pwd=;");
         SqlDataAdapter sda=new SqlDataAdapter("SqlAndProc_Login_Select",conn);
         sda.SelectCommand.CommandType=CommandType.StoredProcedure;
         sda.SelectCommand.Parameters.Add("@name",this.textBox1.Text);
         DataSet ds=new DataSet();
         sda.Fill(ds,"login");
         this.dataGrid1.DataSource=ds.Tables["login"]; 
         
         
        }
        //Sql語句修改
        private void button4_Click(object sender, System.EventArgs e)
        {
         SqlConnection conn=new SqlConnection("server=.;database=DBForADO;uid=sa;pwd=;");
         conn.Open();
         SqlCommand cmd=new SqlCommand("update login set upwd='"+this.textBox2.Text+"' where uname='"+this.textBox1.Text+"'",conn);
         int i=cmd.ExecuteNonQuery();
         if(i==1)
         {
          MessageBox.Show("密碼修改成功!!!");
         }
         conn.Close();
         bind();
        }
        //存儲過程修改
        private void button8_Click(object sender, System.EventArgs e)
        {
         SqlConnection conn=new SqlConnection("server=.;database=DBForADO;uid=sa;pwd=;");
         SqlDataAdapter sda=new SqlDataAdapter("SqlAndProc_Login_Update",conn);
         sda.SelectCommand.CommandType=CommandType.StoredProcedure;
         sda.SelectCommand.Parameters.Add("@name",this.textBox1.Text);
         sda.SelectCommand.Parameters.Add("@pwd",this.textBox2.Text);
         DataSet ds=new DataSet();
         sda.Fill(ds,0,0,"login");
         bind();
        }


       

       

        本站是提供個人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊一鍵舉報。
        轉(zhuǎn)藏 分享 獻花(0

        0條評論

        發(fā)表

        請遵守用戶 評論公約

        類似文章 更多