I want to get the row details of this query

I want to get the row details of this query

Hi @Dikshadudi-8186 ,
What's your meanings? You want to get details of the deleting row? When? Before deleting?
Best regards,
Yijing Sun
Actually i want the detail of column of the row which is going to deleted.
I am here deleting from one table.
Now i want the detail of the column datetime of the row which is going to be deleted. So that i can delete from another table which has the same column

first you should fix the sql injection Security flaw in your code.
you should really use triggers rather than code to handle cascading deletes. but you can use the output clause to get the key fields
var query = @"
delete orders
where prod_id =@pid and user_id=@uid
output deleted.Id
";
using (var conn = new SqlConnection(strcon))
{
conn.Open();
var cmd = new SqlCommand(query, conn);
cmd.Parameters.AddWithValue("@pid", prodid);
cmd.Parameters.AddWithValue("@uid", user_id);
using (var reader = cmd.ExecuteReader())
{
while(reader.HasRows)
{
Console.WriteLine(reader.GetSqlInt32(0));
}
}
}
}
Now i want the detail of the column datetime of the row which is going to be deleted. So that i can delete from another table which has the same column
Seems like a very simply solution. Execute a "SELECT" query to get the record then do the "DELETE". However, needing a DateTime value to delete another records sounds like a design bug.
5 people are following this question.