我有以下使用查询的方法,但 Visual Studio 会引发错误,如图所示。
private void FindOrderData()
{
int intOrder = int.Parse(frmInput.InvoiceOrder);
string InvSql = "SELECT Orders.OrderID, Orders.OrderDate, Orders.Freight," +
"Customers.CompanyName, Customers.City, " +
"(Employees.FirstName + Space(1) + Employees.LastName) As Salesperson " +
"FROM ((Orders " +
"INNER JOIN Customers ON Orders.CustomerID = Customers.CustomerID) " +
"INNER JOIN Employees ON Orders.EmployeeID = Employees.EmployeeID) " +
"WHERE Orders.OrderID = " + "10655";
OleDbConnection cnn = new OleDbConnection(strCon);
OleDbCommand cmdOrder = new OleDbCommand(InvSql, cnn);
cnn.Open();
OleDbDataReader rdrOrder = cmdOrder.ExecuteReader();
// Get CompanyName, City, Salesperson, OrderID, OrderDate and Freight
rdrOrder.Read();
CustomerName = rdrOrder["CompanyName"].ToString();
CustomerCity = rdrOrder["City"].ToString();
SellerName = rdrOrder["Salesperson"].ToString();
SaleID = rdrOrder["OrderID"].ToString();
System.DateTime dtOrder = Convert.ToDateTime(rdrOrder["OrderDate"]);
SaleDate = dtOrder.ToShortDateString();
SaleFreight = Convert.ToDecimal(rdrOrder["Freight"]);
// Get invoice total
GetInvoiceTotal();
rdrOrder.Close();
cnn.Close();
}
string strCon = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\\Users\\Amrit\\Desktop\\Northwind.mdb ;Persist Security Info=False;";