0
我有一個的DevExpress GridView控件與EditingMode = EditFormInplace.
我嘗試用多個表的更新GridView和得到錯誤更新的GridView如何使用多個表
動態SQL生成不針對多個基表支持
我認爲,在dataAdapter中添加UpdateCommand
是必要的。但我不明白如何獲取更新查詢的參數值(來自編輯的行)。
更新DataSource
多個(連接)表的正確方法是什麼?
代碼:
public Form2()
{
InitializeComponent();
dataAdapter = new SqlDataAdapter("select t.Id, t.DT, t.Name, t.Age, l.SecondName from TestTime t left join TestTimeLinked l on l.Id = t.Id", Properties.Settings.Default.MARKETConnectionString);
SqlCommandBuilder commandBuilder = new SqlCommandBuilder(dataAdapter);
DataTable table = new DataTable();
table.Locale = System.Globalization.CultureInfo.InvariantCulture;
dataAdapter.Fill(table);
bindingSource1.DataSource = table;
gridControl1.DataSource = bindingSource1;
}
private void gridView1_RowUpdated(object sender, DevExpress.XtraGrid.Views.Base.RowObjectEventArgs e)
{
using (SqlConnection conn = new SqlConnection(Properties.Settings.Default.MARKETConnectionString))
{
conn.Open();
dataAdapter.Update((DataTable)bindingSource1.DataSource);
}
}