在网格视图中搜索记录

时间:2015-01-04 19:38:59

标签: asp.net vb.net

读取记录已解决。我还有另一个问题,即用户密钥输入正确后,错误信息仍然存在。

    query = "select FoodName, Qty, IngredientName, Quantity, OrderStatus 
             from tblorder, tblorderdetail, tblfood, tblcustomizefooddetail, tblcustomizeingredient, tblordercustomize 
             where tblOrder.OrderId = @OrderId and OrderStatus = @OrderStatus and tblorder.OrderId = tblorderdetail.OrderId and tblorderdetail.FoodId = tblfood.FoodId and tblorderdetail.OrderDetailId = tblordercustomize.OrderDetailId and tblfood.FoodId = tblcustomizefooddetail.FoodId and tblcustomizeingredient.IngredientId = tblcustomizefooddetail.IngredientId and tblordercustomize.IngredientId = tblcustomizeingredient.IngredientId"

    com = New MySqlCommand(query, conn)

    com.Parameters.AddWithValue("@OrderId", txtOrderId.Text)
    com.Parameters.AddWithValue("@OrderStatus", "Pending")

    Dim sqladapter As New MySqlDataAdapter(com)
    sqladapter.Fill(dt)

    If dt.Rows.Count Then
        GridView1.DataSource = dt
        GridView1.DataBind()
    Else
        Label1.Text = "Order ID Doesn't Exist"
    End If

1 个答案:

答案 0 :(得分:0)

让我们拿走你的样本并进行修改:

query = "select FoodName, Qty, IngredientName, Quantity, OrderStatus 
             from tblorder, tblorderdetail, tblfood, tblcustomizefooddetail, tblcustomizeingredient, tblordercustomize 
             where tblOrder.OrderId = @OrderId and OrderStatus = @OrderStatus and tblorder.OrderId = tblorderdetail.OrderId and tblorderdetail.FoodId = tblfood.FoodId and tblorderdetail.OrderDetailId = tblordercustomize.OrderDetailId and tblfood.FoodId = tblcustomizefooddetail.FoodId and tblcustomizeingredient.IngredientId = tblcustomizefooddetail.IngredientId and tblordercustomize.IngredientId = tblcustomizeingredient.IngredientId"

    com = New MySqlCommand(query, conn)

    com.Parameters.AddWithValue("@OrderId", txtOrderId.Text)
    com.Parameters.AddWithValue("@OrderStatus", "Pending")

    Dim adapter as new SqlDataAdapter(com)
adapter.Fill(dt)

if adapter.Tables(0).Rows.Count > 0
        GridView1.DataSource = adapter.Tables(0)
        GridView1.DataBind()
    Else
        Label1.Text = "Order ID Doesn't Exist"
    End If