c# - delete records from 2 tables -


I have to write a question to delete form 2 tables

  remove [policies] ], [BackupSpec] WHERE [PolicyID] = @original_PolicyID  

PloicyID policies have PK in PK and Backupspec

Any suggestions ??

  SqlConnection conn = new SqlConnection (); Conn.ConnectionString = ConfigurationManager.ConnectionStrings ["SumooHAgentDBConnectionString"]. ConnectionString; String SQL = "[Delete from Policies], [Backup Aspec] Where [Policy ID] = @Ariginal_PolicyID"; String sql1 = "Remove from [Backupspec] [Policy ID] = @original_PolicyID"; SqlCommand CMD = New SQL Commands (Esquilla, Con); SqlCommand cmd1 = New SqlCommand (sql1, conn); Cmd.Parameters.AddWithValue ("@User_PolicyID", item); Conn.Open (); Cmd.ExecuteNonQuery (); Conn.Close ();  

You can not remove from two tables at once. This is a limit of SQL Server and thus there is no option for you to send two deletion statements or to define cascade delete on guardian record. I recommend two statements instead of cascade delete because many records are included in the discount because the waterfall removal can cause locking problems. Remember cascade affects any deleted in any of the deleted sources, and so if you are only removing a record Eta time, then it will also be affected when there is no lac The record must be deleted. This will take longer and will increase the number of tables due to the increase in number of hair tables.


Comments

Popular posts from this blog

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -