首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET Framework >

视图中得字段可不可以作为关键字查询,该怎么处理

2011-12-30 
视图中得字段可不可以作为关键字查询//视图代码:create view View_TradingInquires --交易查询With Encryp

视图中得字段可不可以作为关键字查询
//视图代码:
create view View_TradingInquires --交易查询
With Encryption
as
select FleetNetwork.MachineID as 机器编号,FleetNetwork.MachineIP as 机器IP,TradingSerialNumber as 流水号,TradingTradTime as 时间,TradingEnchangType as 兑换方式,SerialList as 流水清单
from TradingInquires,FleetNetwork
where TradingInquires.MachineID=FleetNetwork.MachineID
with check option
//后台代码:
  private void button1_Click(object sender, EventArgs e)
  {
  string strsql = "select * from View_TradingInquires where TradingTradTime between '" + dateTimePicker1.Value + "' and '" + dateTimePicker2.Value + "'";
  ClassLibrary1.BusinssLayerProgrammer.Open();
  dataGridView1.DataSource= ClassLibrary1.BusinssLayerProgrammer.ExecuteQuery(strsql);
  }
我就是想通过2个dateTimePicker提取时间段,然后查询View_TradingInquires视图中这个时间段额信息
但是总提示TradingTradTime无效
不知道怎么办了

[解决办法]
View里的column名字已经是 时间了

TradingTradTime as 时间

因此sql语句中要用时间

string strsql = "select * from View_TradingInquires where 时间 between '" + dateTimePicker1.Value + "' and '" + dateTimePicker2.Value + "'";

这样试一试

热点排行