能不能用视图更新到原数据表
例如,我有一个视图如下:CREATE VIEW dbo.ViewBom
AS
SELECT dbo.Bom.SampleID, dbo.Bom.PartID, dbo.ViewPart.PartName,
dbo.ViewPart.PartSpec, dbo.ViewPart.ColorName, dbo.ViewPart.UnitName,
dbo.Bom.Dosage,dbo.Bom.Dosage
FROM dbo.Bom LEFT OUTER JOIN
dbo.ViewPart ON
dbo.dbo.Bom.PartID = dbo.ViewPart.PartID
我现在将其数据绑定到DataGridView中,代码如下:
SqlConnection conn = new SqlConnection(strConnectionString);
string StrSql = "SELECT * FROM ViewBom ORDER BY PartID";
conn.Open();
SqlDataAdapter sda = new SqlDataAdapter(strSql, conn);
sda.Fill(dataSet, "ViewBom");
BindingSource bs = new BindingSource();
bs.DataSource = dataSet.Table["ViewBom"];
dgv.DataSource = bs;
(注:Bom和ViewPart是两个SQL源表,而ViewBom则是由Bom和ViewPart得到的一个视图)
我现在的问题是:
有没有办法使其在对dgv进年编辑后,直接调用sda.Update()来更新Bom表中的数据?