这是我的 asp.net 代码:
public static void GetInvoices(int client_id)
{
using ( var conn = new SqlConnection( GetConnectionString() ) )
using ( var cmd = conn.CreateCommand() )
{
conn.Open();
cmd.CommandText =
conn.Open();
cmd.CommandText =
@"SELECT o.OrderID, o.OrderDate, o.Status, o.ShipDate, o.PostAmount, sum(p.PaymentAmt) as Paid
FROM Orders o left outer join payment p on o.orderid = p.orderid WHERE o.DistID = @client_id
Group by o.OrderID, o.OrderDate, o.Status, o.ShipDate, o.PostAmount
Order By o.OrderDate Desc";
cmd.Parameters.AddWithValue( "@client_id", client_id );
cmd.ExecuteNonQuery();;
}
}
如何将由此返回的信息(可能返回 0 行)附加到 ListView 控件?
是不是很简单
ListViewInvoices.DataSource = GetInvoices(1);
ListViewInvoices.DataBind();
或者是否有更多涉及将其连接到 sql 查询数据集?