Hi All
i am filling dataadapter by using query which contains joins Means Retraive data from Multiple Table and fill that data into datatable code shows as follows
_problemAdapter = new MySqlDataAdapter("SELECT xr.ID,vw.ID view_ID, vw.DX, vw.DisplayName, xr.Active,xr.Preferred FROM vw_Dignosis vw LEFT JOIN diagnosisXref xr ON vw.ID=xr.View_ID ORDER BY vw.DX;", SupraClasses.SupraConnection.Instance);
cmdBldr = new MySqlCommandBuilder(_problemAdapter);
_problemListTable = new DataTable();
_problemAdapter.Fill(_problemListTable);
table = _problemListTable.Copy();
and then after assigned table to Datagrid ftera changing in datagrid i write following code to Update Adapter Method like this
_problemListTable = (DataTable)Convert.ChangeType(Results.DataSource, typeof(DataTable));
MySqlCommand Insert = new MySqlCommand("INSERT INTO diagnosisXref (view_ID,Active,Preferred) VALUES(@view_ID,@Active,@Preferred)", SupraClasses.SupraConnection.Instance);
Insert.Parameters.Add("@view_ID", MySqlDbType.UInt32, 8, "view_ID");
Insert.Parameters.Add("@Active", MySqlDbType.UInt32, 1, "Active");
Insert.Parameters.Add("@Preferred", MySqlDbType.UInt32, 1, "Preferred");
_problemAdapter.InsertCommand = Insert;
_problemAdapter.MissingSchemaAction = MissingSchemaAction.AddWithKey;
_problemAdapter.Update(_problemListTable);
i want to function like if there is vw.ID view_ID available in DiagnosisXref table then it shold Update the table and not available then Inser New Recod into Xref table
Please Help ASAP Thak you in advance