你会在什么情况下使用Select from without?

问题描述:

我STUDING一个exman,我偶然发现了一个问题的答案与此格式:你会在什么情况下使用Select from without?

public DataTable SueldosHistoricosEmpleado (int idEmpleado) 
{   
    SqlConnection conn = new SqlConnection (ConfigurationManager.ConnectionStrings["conexion"].ConnectionString); 

      SqlDataAdapter da=null; 

      SqlCommand cmd=new SqlCommand(@"SELECT HistoricoSueldos WHERE [email protected]",conn); 

      cmd.Parameters.AddWithValue("@id", this.id); 

      Try{  
       conn.Open();  
        da=new SqlDataAdapter(cmd);  
        Dataset ds=new Dataset(); 
        da.Fill(ds); 
         return ds.Tables[0]; 

          } 
          Catch(Exception) 
          { return null; } 

我理解方法做什么,我唯一的问题是,在选择没有来自。它只是选择一个整个表。 它究竟做了什么?

感谢清除此向上

+0

我不认为这可以工作。 –

+0

我以为是同一件事,就是这个答案。也许他们犯了一个错误,无论哪种方式,我想确保 – EmiL

+0

不要听我的话,等待更多的回应。 –

假设这是C#,代码不能编译,因为该语言是大小写敏感的(例如Trytry)。

如果代码编译完成,它将引发SqlException,因为SQL语句语法无效(没有FROM子句,因此无法解析引用的列名称)。异常处理程序将捕获错误并返回值null