Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/261.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# SQL查询中“_C#_Sql_Sql Server_Conditional Statements - Fatal编程技术网

C# SQL查询中“

C# SQL查询中“,c#,sql,sql-server,conditional-statements,C#,Sql,Sql Server,Conditional Statements,我想获取sql表列值time\u start\u int在time\u end\u int之间的值 我犯了一个错误 “附近的语法不正确您无法写入要在两值查询之间获取的开始。 但您键入的代码在sql中语法不正确,这不是C语言的问题 "...and start_cd >= " + time_start_int + " and " + start_cd + " <= " + time_end_int 测试此代码: SELECT [ID] ,[Available]

我想获取sql表列值time\u start\u int在time\u end\u int之间的值

我犯了一个错误


“附近的语法不正确您无法写入要在两值查询之间获取的开始。 但您键入的代码在sql中语法不正确,这不是C语言的问题

"...and start_cd >= " + time_start_int + " and " + start_cd + " <= " + time_end_int
测试此代码:

 SELECT [ID]
      ,[Available]
      ,[Type]     
  FROM [dbo].[Going]
  where start_cd !=0 or end_cd!=0 and time_end_int <= start_cd <= time_start_int 

希望能对您有所帮助。

不要连接字符串,这会使您容易受到SQL注入的影响。请转换int-ti字符串,然后连接字符串。我不知道您的数据,所以说起来有点困难。
 SELECT [ID]
      ,[Available]
      ,[Type]     
  FROM [dbo].[Going]
  where start_cd !=0 or end_cd!=0 and time_end_int <= start_cd <= time_start_int 
    SELECT [ID]
      ,[Available]
      ,[Type]   FROM [dbo].[Going]
  where start_cd !=0 or end_cd!=0 and (time_end_int <= start_cd and  start_cd <= time_start_int)