Hi, I am attempting to go through a SQL database, find an encrypted string, decrypt it, and then re-encrypt it with a new passphrase. The problem occurs when I try to write to the database while the Reader is still open.
My code roughly looks like:
SqlConnection sc = new SqlConnection(" Server=" + dbserver + ";Database= " + db + ";Trusted_Conne ction=True;Mult ipleActiveResul tSets=True;);
string qs = "SELECT Page, Revision, Content FROM [" + db + "].[dbo].[" + dbtable + "]";
sc.Open();
SqlCommand command = new SqlCommand(qs, sc);
myReader = command.Execute Reader();
while(myReader. Read())
{
...
qs = "UPDATE [wiki_data_test].[dbo].[PageContent_v2] SET Content=@catCon tent WHERE Page=@thePage AND Revision=@theRe vision";
command = new SqlCommand(qs, sc);
command.Execute NonQuery();
...
}
I get the error "Transactio n was deadlocked on lock generic waitable...". I tried to create a separate connection just for the writes, but I get an error stating that I cannot connect while the reader is open.
My code roughly looks like:
SqlConnection sc = new SqlConnection(" Server=" + dbserver + ";Database= " + db + ";Trusted_Conne ction=True;Mult ipleActiveResul tSets=True;);
string qs = "SELECT Page, Revision, Content FROM [" + db + "].[dbo].[" + dbtable + "]";
sc.Open();
SqlCommand command = new SqlCommand(qs, sc);
myReader = command.Execute Reader();
while(myReader. Read())
{
...
qs = "UPDATE [wiki_data_test].[dbo].[PageContent_v2] SET Content=@catCon tent WHERE Page=@thePage AND Revision=@theRe vision";
command = new SqlCommand(qs, sc);
command.Execute NonQuery();
...
}
I get the error "Transactio n was deadlocked on lock generic waitable...". I tried to create a separate connection just for the writes, but I get an error stating that I cannot connect while the reader is open.
Comment