private void btnReplace_Click(object sender, EventArgs e)
{
string strConn = @"Data Source=.;Initial Catalog=CrashDB;Integrated Security=True";
SqlConnection Conn = new SqlConnection(strConn);
Conn.Open();
SqlCommand cmd = new SqlCommand("select * from CrashDB", Conn);
SqlDataReader read = cmd.ExecuteReader();
while (read.Read())
{
string dis_info = (String)read["exception_stack"];
dicCrash[(String)(read["id"].ToString())] = RegexReplace(dis_info);
}
read.Close();
foreach (var key in dicCrash.Keys)
{
string info = dicCrash[key].Replace("'", "''");
String sql = "Update CrashDB Set dis_info ='" + info + "' where id = " + key;
SqlCommand cmd2 = new SqlCommand(sql, Conn);
cmd2.ExecuteNonQuery();
}
Conn.Close();
MessageBox.Show("替换完成");
}