大家帮我看看这个问题是怎么回事
using System;using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class vote : System.Web.UI.Page
{
private string voteID = "1";
protected void Page_Load(object sender, 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;
//查询对应的选举投票项目
SqlCommand cmdItem = new SqlCommand(" select voteDetailsID,voteItem from voteDetails shere voteID=" + this.voteID,con );
SqlDataReader sdr = cmdItem.ExecuteReader();
this.rBtnItems.DataSource = sdr;
this.rBtnItems.DataTextField = "voteItem";
this.rBtnItems.DataValueField="voteDetailsID";
this.rBtnItems.DataBind();
sdr.Close();
//关闭连接
con.Close();
}
}
运行后产生错误(如下):
用户代码未处理 System.Data.SqlClient.SqlException
Message="第 1 行: 'voteID' 附近有语法错误。"
Source=".Net SqlClient Data Provider"
ErrorCode=-2146232060
Class=15
LineNumber=1
Number=170
Procedure=""
Server="."
State=1
StackTrace:
在 System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
在 System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
在 System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
在 System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
在 System.Data.SqlClient.SqlDataReader.ConsumeMetaData()
在 System.Data.SqlClient.SqlDataReader.get_MetaData()
在 System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
在 System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
在 System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
在 System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
在 System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
在 System.Data.SqlClient.SqlCommand.ExecuteReader()
在 vote.Page_Load(Object sender, EventArgs e) 位置 c:\Documents and Settings\Administrator\My Documents\Visual Studio 2005\WebSites\vote\vote.aspx.cs:行号 28
在 System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)
在 System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)
在 System.Web.UI.Control.OnLoad(EventArgs e)
在 System.Web.UI.Control.LoadRecursive()
在 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
--------------------编程问答-------------------- shere voteID
=>
WHERE voteID
补充:.NET技术 , ASP.NET