System.Data.SqlClient.SqlException: 'a' 附近有语法错误。
这个是程序:publicpartialclassDiscountWare:System.Web.UI.Page{protectedvoidPage_Load(object...
这个是程序:
public partial class DiscountWare : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string connstr = ConfigurationManager.ConnectionStrings["SuperMarketConnectionString"].ConnectionString;
SqlConnection sqlConn = new SqlConnection(connstr);
sqlConn.Open();
string str = "select splb_TypeName from T_WareType";
SqlCommand cmd = new SqlCommand(str, sqlConn);
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
DropDownList1.Items.Add(dr["splb_TypeName"].ToString());
}
GridView1.DataSourceID = "SqlDataSource1";
}
}
protected void Button1_Click(object sender, EventArgs e)
{
string connstr = ConfigurationManager.ConnectionStrings["SuperMarketConnectionString"].ConnectionString;
SqlConnection sqlConn = new SqlConnection(connstr);
sqlConn.Open();
string str = "SELECT sp_WareName,sp_AllSum,sp_SellSum,sp_Price,sp_Information,splb_TypeName";
str = str + "FROM T_Ware a JOIN T_WareType b ON a.splb_TypeID=b.splb_TypeID where";
str = str + "b.splb_TypeName=" + DropDownList1.SelectedValue.ToString().Trim() + "";
if (TextBox1.Text != "")
{
str = str + "and a.sp_WareName like" + "%" + TextBox1.Text.Trim() + "%";
}
this.GridView1.DataSourceID = null;
SqlDataSource1.SelectCommand = str;
GridView1.DataSourceID = "SqlDataSource1";
}
} 展开
public partial class DiscountWare : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string connstr = ConfigurationManager.ConnectionStrings["SuperMarketConnectionString"].ConnectionString;
SqlConnection sqlConn = new SqlConnection(connstr);
sqlConn.Open();
string str = "select splb_TypeName from T_WareType";
SqlCommand cmd = new SqlCommand(str, sqlConn);
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
DropDownList1.Items.Add(dr["splb_TypeName"].ToString());
}
GridView1.DataSourceID = "SqlDataSource1";
}
}
protected void Button1_Click(object sender, EventArgs e)
{
string connstr = ConfigurationManager.ConnectionStrings["SuperMarketConnectionString"].ConnectionString;
SqlConnection sqlConn = new SqlConnection(connstr);
sqlConn.Open();
string str = "SELECT sp_WareName,sp_AllSum,sp_SellSum,sp_Price,sp_Information,splb_TypeName";
str = str + "FROM T_Ware a JOIN T_WareType b ON a.splb_TypeID=b.splb_TypeID where";
str = str + "b.splb_TypeName=" + DropDownList1.SelectedValue.ToString().Trim() + "";
if (TextBox1.Text != "")
{
str = str + "and a.sp_WareName like" + "%" + TextBox1.Text.Trim() + "%";
}
this.GridView1.DataSourceID = null;
SqlDataSource1.SelectCommand = str;
GridView1.DataSourceID = "SqlDataSource1";
}
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询