我有一个数据库"D:\ MDF CONNECTION SAMPLE\BIN\DEBUG\HARMDATABASE.MDF".我试图使用以下代码分离或重命名它:
SqlConnection conn = new SqlConnection("Data Source=.\\MSSQLSERVER2008;database=Master;Integrated Security=True;");
SqlCommand cmd = new SqlCommand("", conn);
cmd.CommandText = @"sys.sp_detach_db D:\MDF CONNECTION SAMPLE\BIN\DEBUG\HARMDATABASE.MDF";
conn.Open();
cmd.ExecuteNonQuery();
cmd.Dispose();
conn.Dispose();
Run Code Online (Sandbox Code Playgroud)
但是得到一个错误:
'\'附近的语法不正确.
我想用C#编写这段代码:
//
excelCellrange = excelSheet.get_Range("B1", "B1");
excelCellrange.Formula = "=IF(A1="Harm",100)";
//Copy formula to other cells:
excelCellrange = excelSheet.get_Range("B2", B10);
excelCellrange.PasteSpecial(Excel.XlPasteType.xlPasteFormulas);
Run Code Online (Sandbox Code Playgroud)
但我不能写"Harm""".怎么解决这个?