我在 ASP.Net 中设计一个物流网站,客户可以下订单,订单将插入数据库。我想,当新订单插入数据库时,它会自动向员工发送新订单通知。问题是,当数据库更改时,如何操作以下代码来获取实时通知?
public class FreightOrderList
{
int customerID = 0;
public int CustomerID
{
get { return customerID; }
set { customerID = value; }
}
string email = string.Empty;
public FreightOrderList()
{
//default Cons
}
public FreightOrderList(int _customerID)
{
this.customerID = _customerID;
}
public DataSet displayOrders()
{
string ConString = ConfigurationManager.ConnectionStrings["LGDB"].ToString();
SqlConnection sqlConnectionObj = new SqlConnection(ConString);
SqlDataAdapter sqlDataAdapterObj = new SqlDataAdapter();
DataSet dataSetObj = new DataSet();
sqlDataAdapterObj.SelectCommand = new SqlCommand();
sqlDataAdapterObj.SelectCommand.Connection = sqlConnectionObj;
sqlDataAdapterObj.SelectCommand.CommandText = "customerShipOrderProc";
sqlDataAdapterObj.SelectCommand.CommandType = CommandType.StoredProcedure;
sqlConnectionObj.Open();
sqlDataAdapterObj.SelectCommand.Parameters.AddWithValue("customerID", this.CustomerID);
sqlDataAdapterObj.Fill(dataSetObj,"customerShipOrder");
sqlConnectionObj.Close();
return dataSetObj;
}
}