请各位大哥帮我看一下,具体的我就不说了,里面有我建立的SQL表名,这里是我在VS.NET下写的同时进行两个投票的代码,但是运行时总是提示我36行附近有错误,就是这一行附近SqlDataReader sdr=cmd.ExecuteReader();,但是我还是没发现哪里错了,麻烦帮我看一下namespace workText.userControls
{
using System;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
/// <summary>
/// voteControl 的摘要说明。
/// </summary>
public class voteControl : System.Web.UI.UserControl
{
protected System.Web.UI.WebControls.Label lblNetVote;
protected System.Web.UI.WebControls.Button btnVote;
protected System.Web.UI.WebControls.Button btnResult;
protected System.Web.UI.WebControls.Label lblLikeLang;
protected System.Web.UI.WebControls.RadioButtonList radNetVote;
protected System.Web.UI.WebControls.RadioButtonList radLikeLang;
private string firstGroup="1";
private string secondGroup="2";
private void Page_Load(object sender, System.EventArgs e)
{
//连接数据库并为投票总类设置标题
SqlConnection con=DB.createConnection();
con.Open();
SqlCommand cmd=new SqlCommand("select voteType from votemain where voteID="+firstGroup,con);
string firstLbl=Convert.ToString(cmd.ExecuteScalar());
this.lblNetVote.Text=firstLbl;
cmd.CommandText="select voteType from votemain where voteID="+secondGroup;
string secondLbl=Convert.ToString(cmd.ExecuteScalar());
this.lblLikeLang.Text=secondLbl;
//为每个投票项进行设置
cmd.CommandText="select voteItemID,voteItem from votecontent where="+firstGroup;
SqlDataReader sdr=cmd.ExecuteReader();
this.radNetVote.DataValueField="voteItemID";
this.radNetVote.DataTextField="voteItem";
this.radNetVote.DataSource=sdr;
this.radNetVote.DataBind();
sdr.Close();
cmd.CommandText="select voteItemID,voteItem from voteconten where="+secondGroup;
sdr=cmd.ExecuteReader();
this.radLikeLang.DataValueField="voteItemID";
this.radLikeLang.DataTextField="voteItem";
this.radLikeLang.DataSource=sdr;
this.radLikeLang.DataBind();
sdr.Close();
con.Close();
} #region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器
/// 修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.btnVote.Click += new System.EventHandler(this.btnVote_Click);
this.Load += new System.EventHandler(this.Page_Load); }
#endregion private void btnVote_Click(object sender, System.EventArgs e)
{
SqlConnection con=DB.createConnection();
con.Open();
SqlCommand cmd=new SqlCommand("update voteconten set voteItemCount=voteItemCount+1 where voteID="+this.radNetVote.SelectedValue,con);
cmd.ExecuteNonQuery();
cmd.CommandText="update voteconten set voteItemCount=voteItemCount+1 where voteID="+this.radLikeLang.SelectedValue;
cmd.ExecuteNonQuery();
con.Close();
}
}
}

解决方案 »

  1.   

    cmd.CommandText="select voteItemID,voteItem from votecontent where 这里应该是一个字段哟,老兄=" + firstGroup;
      

  2.   

    同一楼上所言,这样的代码自己多检查下就出来了
    -------------------------------------------------------------------------
    .Net技术讨论群14272327,欢迎爱好c#和asp.net的同志加入~队伍正在不断壮大中...
      

  3.   

    SqlCommand cmd=new SqlCommand("select voteType from votemain where voteID="+firstGroup,con);cmd.CommandText="select voteItemID,voteItem from voteconten where="+secondGroup;自己仔细看一下吧,太明显咯(”=“前面的字段呢?)