【发布时间】:2011-05-04 18:38:47
【问题描述】:
这是我的查询:
select reporttime, datapath, finalconc, instrument from batchinfo
join qvalues on batchinfo.rowid=qvalues.rowid where qvalues.rowid
in (select rowid from batchinfo where instrument LIKE '%TF1%' and reporttime
like '10/%/2010%') and compound='ETG' and name='QC1'
我是这样运行的:
// Create a database connection object using the connection string
OleDbConnection myConnection = new OleDbConnection(myConnectionString);
// Create a database command on the connection using query
OleDbCommand myCommand = new OleDbCommand(mySelectQuery, myConnection);
它不返回任何结果。
当我在 sql server GUI 中尝试同样的查询时,它会返回很多行
c#的查询语法有问题吗?
请注意,如果我像select * from table 这样简化查询,则没有问题
【问题讨论】:
-
您能否提供实际将值分配给
mySelectQuery的代码? -
运行查询分析器以查看正在执行的实际查询(如果有)
-
您的
reporttime列是什么数据类型?顾名思义,它是暂时的(DATE、DATETIME等),但通配符的使用表明它是文本(VARCHAR等)。 -
@oneday 我的朋友是 varchar
-
@postman 把答案变成你绝对正确的答案
标签: c# .net sql sql-server-2008 select