逐步说明以下编码 [英] explain following coding in step by step
问题描述
任何人都可以逐步按照c#代码向我解释:
Can anyone explain me following c# code in step by step:
public void update(string id)
{
string ids = Request.QueryString["ids"];
Session["ID"] = ids.ToString();
con.Open();
SqlCommand cmd = new SqlCommand("select * from product where pro_id=''" + ids + "''", con);
SqlDataReader dr = cmd.ExecuteReader();
if (dr.HasRows)
{
while (dr.Read())
{
txtpro_id.Text = dr["pro_id"].ToString();
txtpro_name.Text = dr["pro_name"].ToString();
txtdescription.Text = dr["description"].ToString();
txtpriority.Text = dr["priority"].ToString();
txtytubeurl.Text = dr["ytube_url"].ToString();
txtprice.Text = dr["price"].ToString();
}
dr.Close();
}
con.Close();
推荐答案
1-
public void update(string id)
您可以通过粘贴一个参数作为String Id来编写方法
2-
you writting a method by pasing one parameter as String Id
2-
string ids = Request.QueryString["ids"];
您将值存储在来自QueryString的"ids"中,这些值来自某个地方,就像您使用QueryString将值从一页传递到另一页一样
3-
you storing value in ''ids'' from QueryString that come from somewhere like you passing value from one page to another using QueryString
3-
Session["ID"] = ids.ToString();
您将QueryString值存储在会话中
4- con.Open();
通过调用connectionString值来打开连接.
5-
you storing QueryString value in session
4- con.Open();
opening the connention by calling the connectionString value.
5-
SqlCommand cmd = new SqlCommand("select * from product where pro_id='" + ids + "'", con);
在SQLCommant属性中触发查询和存储
6-
firing the Query and Storing in SQLCommant Property
6-
SqlDataReader dr = cmd.ExecuteReader();
使用SQlDataReader执行命令.数据读取器仅读取一行,而丢弃所有其他行
7-
executing the command using SQlDataReader. Data reader is read only one row and discard all other row
7-
if (dr.HasRows)
HasRows用于检查dr是否具有行.如果dr包含行,则它将进入循环内
8-
HasRows is used to check dr has row or not.if dr contain row then it will go inside the loop
8-
while (dr.Read())
{
txtpro_id.Text = dr["pro_id"].ToString();
txtpro_name.Text = dr["pro_name"].ToString();
txtdescription.Text = dr["description"].ToString();
txtpriority.Text = dr["priority"].ToString();
txtytubeurl.Text = dr["ytube_url"].ToString();
txtprice.Text = dr["price"].ToString();
}
将值一一设置为控件
9-
setting the value to the control one by one
9-
dr.Close();
关闭数据读取器
10-
closing the datareader
10-
con.Close();
关闭连接
closing the connection
这篇关于逐步说明以下编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!