This is how i return Datatable
Then how to assign that datatable to list<> (is it possible to assign datatable to list<>) ??
public DataTable Vehiclelist(string Vehicle)
{
SqlCommand newCmd = conn.CreateCommand();
newCmd.Connection = conn;
newCmd.CommandType = CommandType.Text;
newCmd.CommandText = "SELECT * from where Vehicle_No ='" + Vehicle+ "'";
SqlDataAdapter da = new SqlDataAdapter(newCmd);
DataTable dt = new DataTable();
da.Fill(dt);
conn.Close();
return dt;
}
上面的代码段从表中读取数据并作为数据表返回然后告诉如何将此数据表分配给后面代码中的 List<> 或者告诉如何从数据库中读取数据作为 List<>