I am pulling an order ID from a previous page to select a specific order from a table and that works fine. I also need to get the CustomerID from that table and query the customer table to return the entry with that ID.
我从上一页提取订单ID以从表中选择特定订单,并且工作正常。我还需要从该表中获取CustomerID并查询customer表以返回具有该ID的条目。
@{
var id=Request["id"];
var SQLSELECT3 = "SELECT * FROM Ordr WHERE ID=@0";
var db = Database.Open("OMD");
var ordr = db.QuerySingle(SQLSELECT3,id);
var oCustomerID=ordr.CustomerID;
var oStatus=ordr.Status;
var oID=ordr.ID;
var oDate=ordr.Date;
var oService=ordr.Service;
var oNotes=ordr.Notes;
var SQLSELECT = "SELECT * FROM Customer WHERE ID = @oCustomerID";
var customer = db.QuerySingle(SQLSELECT,id);
var cLastName=customer.LastName;
var cFirstName=customer.FirstName;
var cAddress=customer.Address;
var cCity=customer.City;
var cState=customer.State;
var cZip=customer.Zip;
var cPhone1=customer.Phone1;
var cPhone2=customer.Phone2;
var cEmail=customer.Email;
}
1 个解决方案
#1
1
Change your query to
将您的查询更改为
var SQLSELECT = "SELECT * FROM Customer WHERE ID = @0";
var customer = db.QuerySingle(SQLSELECT, (int)ordr.CustomerID);
Nothing to do with your issue, but I don't understand why you transfer all the values you get from the query to another set of variables. That's a huge amount of unnecessary typing, in my opinion.
与您的问题无关,但我不明白为什么您将从查询中获得的所有值转移到另一组变量。在我看来,这是一个巨大的不必要的打字。
#1
1
Change your query to
将您的查询更改为
var SQLSELECT = "SELECT * FROM Customer WHERE ID = @0";
var customer = db.QuerySingle(SQLSELECT, (int)ordr.CustomerID);
Nothing to do with your issue, but I don't understand why you transfer all the values you get from the query to another set of variables. That's a huge amount of unnecessary typing, in my opinion.
与您的问题无关,但我不明白为什么您将从查询中获得的所有值转移到另一组变量。在我看来,这是一个巨大的不必要的打字。