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";
}
} 展开
1个回答
网易云信
2023-12-06 广告
2023-12-06 广告
网易云信提供一站式的 1 对 1 UIKit 组件库,可以更快地搭建 1 对 1 社交平台,能够快速实现音视频呼叫、音视频通话、1对1消息发送、美颜和礼物功能,直接可以复用我们的组件源码就可以了。优势:1、全套1对1 UI组件,接入更快;2...
点击进入详情页
本回答由网易云信提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询