数据源'ObjectDataSource1'中的DataSet不包含任何表 [英] The DataSet in data source 'ObjectDataSource1' does not contain any tables
本文介绍了数据源'ObjectDataSource1'中的DataSet不包含任何表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个问题如上所示。我有一个productdetail.aspx和一个addtocart btn。
当我点击添加到购物车btn我有这个错误。
这个是我的DAL
I have a problem as show above. I have a productdetail.aspx and a addtocart btn in it.
when i click add to cart btn i have this error.
this is my DAL
public DataSet GetShoppingCart(string userID)
{
SqlConnection conn;
StringBuilder sql;
SqlDataAdapter da;
DataSet PCData;
conn = dbConn.GetConnection();
PCData = new DataSet();
sql = new StringBuilder();
sql.AppendLine("SELECT * FROM BQ_ShoppingCart");
sql.AppendLine("WHERE userID = @userID");
try
{
conn.Open();
da = new SqlDataAdapter(sql.ToString(), conn);
da.SelectCommand.Parameters.AddWithValue("@userID", userID);
da.Fill(PCData);
}
catch (Exception ex)
{
errMsg = ex.Message;
}
finally
{
conn.Close();
}
return PCData;
}
MY BLL
MY BLL
[System.ComponentModel.DataObjectMethodAttribute
(System.ComponentModel.DataObjectMethodType.Select, true)]
public DataSet GetShoppingCart(string userID)
{
BQ_DAL dlSc = new BQ_DAL();
return dlSc.GetShoppingCart(userID);
}
推荐答案
您好b $ b
如果您追踪您的计划,您可以看你的StringBuilder
输出是错误的,因为你没有在第一个slq.AdppendLine
和第二个sql.AppendLine
所以你的输出是:
Hi
If you are trace your program you can see yourStringBuilder
output is a wrong because you have not blink between firstslq.AdppendLine
and secondsql.AppendLine
so your output is a:
SELECT * FROM BQ_ShoppingCartWHERE userID = @userID
Where子句是错误的,所以你需要在第一个sql.AppendLine结束时闪烁,为此你不需要 StringBuilder
和我不知道你用过它吗?
Where clause is a wrong so you need a blink at the end of first sql.AppendLine how ever you don`t need to the StringBuilder
for this purpose and I don`t know what you used it?
sql.AppendLine("SELECT * FROM BQ_ShoppingCart ");
sql.AppendLine("WHERE userID = @userID");
您可以非常轻松地将查询字符串设置为:
You have really easy way for making query string same as:
String sqlQuery = "SELECT * FROM BQ_ShoppingCart WHERE userID = @userID";
最好的问候。
Best Regards.
这篇关于数据源'ObjectDataSource1'中的DataSet不包含任何表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文