本文介绍了如何撤消变量值并粘贴模板字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Hi! All my friends!
Please help me, it’s my first project for airport (student practice). I’m learning coding C# My Data base connected to forms DataGridView and I see any changes real time (used SqlDependency).
Next step, how can I do for example when changes one column in Database (flight condition) withdraw "flight_number, destination_airport" and paste this information (variable value) in template string "Dear passenger ''flight_number'' to ''destination_airport'' was canceled. (passenger display notifications).
How can I do for C#, please give an example code. sorry my English, i hope you understand me. Thank you!
我尝试了什么:
What I have tried:
//Load Data
void LoadData()
{
DataTable dt = new DataTable();
if (con.State == ConnectionState.Closed)
{
con.Open();
}
SqlCommand cmd = new SqlCommand("SELECT flight_number, destination_airport, flight_status, checkin_place, gate FROM DFP", con);
cmd.Notification = null;
SqlDependency de = new SqlDependency(cmd);
de.OnChange += new OnChangeEventHandler(de_OnChange);
dt.Load(cmd.ExecuteReader(CommandBehavior.CloseConnection));
dataGridView1.DataSource = dt;
}
public void de_OnChange(object sender, SqlNotificationEventArgs e)
{
SqlDependency de = sender as SqlDependency;
de.OnChange -= de_OnChange;
if (OnNewHome != null)
{
OnNewHome();
}
}
}
推荐答案
这篇关于如何撤消变量值并粘贴模板字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!