I have to write a query to delete form 2 tables
DELETE FROM [Policies],[BackupSpec] WHERE [PolicyID] = @original_PolicyID
PloicyID is PK in Policies and FK in Backupspec
any suggestions??
SqlConnection conn = new SqlConnection();
conn.ConnectionString = ConfigurationManager.ConnectionStrings["SumooHAgentDBConnectionString"].ConnectionString;
string sql = "DELETE FROM [Policies],[BackupSpec] WHERE [PolicyID] = @original_PolicyID";
string sql1 = "DELETE FROM [Backupspec] WHERE [PolicyID] = @original_PolicyID";
SqlCommand cmd = new SqlCommand(sql, conn);
SqlCommand cmd1 = new SqlCommand(sql1, conn);
cmd.Parameters.AddWithValue("@original_PolicyID", item);
conn.Open();
cmd.ExecuteNonQuery();
conn.Close();