protected void show_lib()
{
string cid = Request.QueryString["cid"];
string strconn = ConfigurationSettings.AppSettings["strconn"];
SqlConnection conn = new SqlConnection(strconn);
string strsql = "select * from View_lib_report where Cid='" + cid + "' and Sid='" + Session["stuID"] + "'";
SqlCommand cmd = new SqlCommand(strsql, conn);
try
{
conn.Open();
SqlDataReader sda = cmd.ExecuteReader();
while (sda.Read())
{
this.lbname.Text = sda.GetValue(1).ToString();
this.lbmajor.Text = sda.GetValue(3).ToString();
this.lbgrade.Text = sda.GetValue(2).ToString();
this.lbClass.Text = sda.GetValue(4).ToString();
this.ddlTitle.Items.Add(sda.GetValue(6).ToString());
this.ddlTeacher.Items.Add(sda.GetValue(7).ToString());
this.TextArea1.Value = sda.GetValue(8).ToString();
this.Textarea2.Value = sda.GetValue(9).ToString();
}
}
catch
{
return;
}
finally
{
cmd.Dispose();
conn.Close();
}
}
{
string cid = Request.QueryString["cid"];
string strconn = ConfigurationSettings.AppSettings["strconn"];
SqlConnection conn = new SqlConnection(strconn);
string strsql = "select * from View_lib_report where Cid='" + cid + "' and Sid='" + Session["stuID"] + "'";
SqlCommand cmd = new SqlCommand(strsql, conn);
try
{
conn.Open();
SqlDataReader sda = cmd.ExecuteReader();
while (sda.Read())
{
this.lbname.Text = sda.GetValue(1).ToString();
this.lbmajor.Text = sda.GetValue(3).ToString();
this.lbgrade.Text = sda.GetValue(2).ToString();
this.lbClass.Text = sda.GetValue(4).ToString();
this.ddlTitle.Items.Add(sda.GetValue(6).ToString());
this.ddlTeacher.Items.Add(sda.GetValue(7).ToString());
this.TextArea1.Value = sda.GetValue(8).ToString();
this.Textarea2.Value = sda.GetValue(9).ToString();
}
}
catch
{
return;
}
finally
{
cmd.Dispose();
conn.Close();
}
}
解决方案 »
- 在一个已经有数据的gridview中,有哪些方法可以把这些数据导入到数据库??
- c# 求余问题
- 哪儿可以下载带checkbox的treeview控件,用于webform的
- 求企业人事管理系统"源码"(送高分)
- try catch 好稀奇的问题
- C#,Java or C++/CLI
- UserControl 接口 传值 高手 200分
- 怎样实现窗体失去焦点事件?
- vs2010中,对sqlite的读写有原生支持吗?还是要下载驱动的?
- 请教各位:如何将一个DataSet1中DataTable的数据改变,更新到另一个DataSet2中,两个DataSet结构完全一样,都是从XML中读出数据?(在线
- C# 如何实现图片转换为gft格式
- 字符串包含的算法问题(求助)
1.Request.Form:获取以POST方式提交的数据(接收Form提交来的数据); 2.Request.QueryString:获取地址栏参数(以及以GET方式提交的数据) 3.Request:包含以上两种方式(优先获取GET方式提交的数据),它会在QueryString、Form、ServerVariable中都搜寻一遍。 而且有时候也会得到不同的结果。如果你仅仅是需要Form中的一个数据,但是你使用了Request而不是Request.Form,那么程序将在QueryString、ServerVariable中也搜寻一遍。如果正好你的QueryString或者ServerVariable里面也有同名的项,你得到的就不是你原本想要的值了。要养成习惯,最起码为了网页的完整,你也得加上NULL处理呀。呵呵if(cid==null)
{}
else
{}
。做非空值判断也只能给cid一个默认值而已
protected void Page_Load(object sender, EventArgs e)
{
string cid = Request.QueryString["cid"];
Response.Write(cid);
}