新学ASP.NET 刚大概知道ASP.NET连接数据库的方法 不过还有点儿问题

本文详细介绍了使用 C# 进行数据库操作的过程,包括连接数据库、查询数据、更新数据等关键步骤,并解释了代码中 this 的含义。

   this.sqlcon.ConnectionString   =   "server=SEANFISH;database=Students;uid=sa;pwd=..  ";    
   this.sqlcom=sqlcon.CreateCommand();    
   this.sqlcom.CommandText   ="SELECT  *   FROM   Students";    
   this.sqldap.SelectCommand   =   this.sqlcom;    
   this.sqlcon.Open();    
   this.sqldap.Fill(ds,"Students");    
   this.sqlcon.Close();    
   ds.Tables["Students"].BeginLoadData();    
   System.Data.DataRow dr=ds.Tables["Students"].Rows[0];                                                                       
                                          
   ds.Tables["Students"].EndLoadData();    
   System.Data.SqlClient.SqlCommandBuilder sqlcb=new System.Data.SqlClient.SqlCommandBuilder(sqldap);        
                                  
   this.sqlcon.Open();    
   this.sqldap.Update(ds,"Students");     
                      
   this.sqlcon.Close();    
   this.ds.Tables["Students"].AcceptChanges();
   try
   {
     sqlcon.Open();
    Response.Write("连接成功!");

   }
   catch
   {
    Response.Write(" 连接失败!");
   }
   this.DataGrid1.DataSource = ds.Tables["Students"].DefaultView;
   this.DataGrid1.DataBind(); 

算是弄好了 可是加粗的那几段代码还是不知道什么意思 还有this在这里是干什么的?

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值