protected void Page_Load(object sender, EventArgs e)
{
string VoteID = Request.QueryString["VoteID"].ToString();
SqlConnection con = DB.createConnection();
con.Open();
SqlCommand cmdItem = new SqlCommand("select * from VoteDetails where VoteID="+VoteID,con);
SqlDataReader sdr = cmdItem.ExecuteReader();
while (sdr.Read())
{
Response.Write("<font size='5' color='red'>" + sdr.GetString(2)+"--" + sdr.GetInt32(3) + "</font><br>");
}
con.Close();
}
------------------------------------------------
SqlCommand cmdItem = new SqlCommand("select * from VoteDetails where VoteID="+VoteID,con);
最后的Con一定不要忘了。
sdr在循环读取的时候是用的Read,读取数据库的时候用的是:sdr.GetString(2)+"--" + sdr.GetInt32(3)
sdr.GetString(0) 表示数据库中的第一个字段. 类型一定要匹配.
{
string VoteID = Request.QueryString["VoteID"].ToString();
SqlConnection con = DB.createConnection();
con.Open();
SqlCommand cmdItem = new SqlCommand("select * from VoteDetails where VoteID="+VoteID,con);
SqlDataReader sdr = cmdItem.ExecuteReader();
while (sdr.Read())
{
Response.Write("<font size='5' color='red'>" + sdr.GetString(2)+"--" + sdr.GetInt32(3) + "</font><br>");
}
con.Close();
}
------------------------------------------------
SqlCommand cmdItem = new SqlCommand("select * from VoteDetails where VoteID="+VoteID,con);
最后的Con一定不要忘了。
sdr在循环读取的时候是用的Read,读取数据库的时候用的是:sdr.GetString(2)+"--" + sdr.GetInt32(3)
sdr.GetString(0) 表示数据库中的第一个字段. 类型一定要匹配.
浙公网安备 33010602011771号