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在这里是干什么的?
本文详细介绍了使用 C# 进行数据库操作的过程,包括连接数据库、查询数据、更新数据等关键步骤,并解释了代码中 this 的含义。
434

被折叠的 条评论
为什么被折叠?



