setlocal enabledelayedexpansion
仅适用于批处理文件吗?如何在cmd提示符中使用setlocal enabledelayedexpansion
?
答案 0 :(得分:0)
您可以使用命令OleDbCommand cmd = new OleDbCommand("SELECT Table1.Cd_AtributosNormais as Cd_AtributosNormais, Table2.Nm_Atr as Nm_Atr FROM Table1 Left outer join Table2 on Table1.Cd_AtributosNormais = Table2.Cd_AtributosNormais", cn);
OleDbDataReader reader = cmd.ExecuteReader();
DataTable table = new DataTable();
table.Load(reader);
DataRow row = table.NewRow();
row["Nm_Atr"] = "";
table.Rows.InsertAt(row, 0);
this.btCmbAtkBaAtr1.DataContext = table.DefaultView;
this.btCmbAtkBaAtr1.DisplayMemberPath = "Nm_Atr";
this.btCmbAtkBaAtr1.SelectedValuePath = "Cd_AtributosNormais";
cmd.ExecuteNonQuery();
reader.Close();
reader.Dispose();
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
cn.Close();
cn.Dispose();
}
来自cmd /V:ON
:
cmd /?
答案 1 :(得分:0)
从我的CMD窗口中了解示例:Copy&Paste
:
==>echo !os! %pp%
!os! %pp%
==>cmd /E:ON /V:ON /K set "pp=yy" & set pp & echo !os! !pp!
==>echo !os! %pp%
Windows_NT yy
==>exit
Environment variable pp not defined
!os! !pp!
==>cmd /E:ON /V:ON /K set "pp=yy" ^& set pp ^& echo !os! !pp!
pp=yy
Windows_NT yy
==>echo !os! %pp%
Windows_NT yy
==>exit
==>echo !os! %pp%
!os! %pp%
==>
说明:
echo !os! %pp%
返回!os! %pp%
,显示已停用的延迟扩展和当前CLI中未定义的pp
变量; cmd /E:ON /V:ON /K set "pp=yy" & set pp & echo !os! !pp!
什么都不返回,Windows命令解释器的新实例已启用延迟扩展(请参阅echo !os! %pp%
输出); exit
在父CLI实例中返回set pp & echo !os! !pp!
的结果:Environment variable pp not defined
和!os! !pp!
; cmd /E:ON /V:ON /K set "pp=yy" ^& set pp ^& echo !os! !pp!
在新的CLI实例中返回pp=yy
和Windows_NT yy
(请注意&
转义的所有^
}; echo !os! %pp%
在新的CLI实例中返回Windows_NT yy
(它会在子项中显示延迟扩展已启用和pp
变量已定义 CLI); exit
到父CLI实例; echo !os! %pp%
再次返回!os! %pp%
。