[CODE] private void Page_Load(object sender, System.EventArgs e)
{
//创建连接
SqlConnection con=DB.createConnection();
con.Open();
//查询选举的标题
SqlCommand cmd=new SqlCommand("select voteTitle from voteMaster where voteId=" +this.voteId,con);
string title=Convert.ToString(cmd.ExecuteScalar());
this.LblTitle.Text=title;
}[/CODE]
改成
[CODE]private void Page_Load(object sender, System.EventArgs e)
{
//创建连接
string title = "";
try
{
SqlConnection con=DB.createConnection();
con.Open();
//查询选举的标题
SqlCommand cmd=new SqlCommand("select voteTitle from voteMaster where voteId=" +this.voteId,con);
title = Convert.ToString(cmd.ExecuteScalar());
}
catch(Exception exp)
{
MessageBox.Show(exp.Message);
}
this.LblTitle.Text=title;
}[/CODE]