0

我的 SQL 查询有问题。问题在于IN ....,但我不知道如何纠正它。这是查询:

SELECT *
FROM Reports, Games, Developers
WHERE Game = SpelID
  AND Developer = IDDvl
  AND Land IN[‘Japan’,‘USA’,‘UK’,‘Indië’,‘Duitsland’,‘Zweden’]

这是错误消息:

An unhandled exception of type 'System.Data.OleDb.OleDbException'
    occurred in System.Data.dll

In operator without () in query expression 'Game = SpelID AND Developer = IDDvl
    AND Land IN [‘Japan’, ‘USA’, ‘UK’, ‘Indië’, ‘Duitsland’, ‘Zweden’]'.
4

4 回答 4

3
    dagoederen = New OleDb.OleDbDataAdapter("SELECT * FROM Reports , Games, 
Developers WHERE Game = SpelID AND Developer = IDDvl AND Land IN (‘Japan’, 
‘USA’, ‘UK’, ‘Indië’, ‘Duitsland’, ‘Zweden’)", connectie)

您需要替换[ ]()afterIN

于 2013-11-11T08:23:17.430 回答
0

答案在提供的错误“查询表达式中没有 () 的运算符中”中指定。将 IN T-SQL 的“[]”替换为“()”

于 2013-11-11T08:31:00.140 回答
0

使用右括号和引号:

SELECT * 
FROM Reports , Games, Developers 
WHERE Game = SpelID AND 
      Developer = IDDvl AND 
      Land IN ('Japan', 'USA', 'UK', 'Indië', 'Duitsland', 'Zweden')
于 2013-11-11T08:26:06.533 回答
0

用此代码替换

 Imports System.Data.OleDb
 Public Class Form1
 Private Sub cmdsql1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdsql1.Click
connectie.Open()

Dim dagoederen As Data.OleDb.OleDbDataAdapter
 dagoederen = New OleDb.OleDbDataAdapter("SELECT * FROM Reports , Games, Developers WHERE Game = SpelID AND Developer = IDDvl AND Land IN (‘Japan’, ‘USA’, ‘UK’, ‘Indië’, ‘Duitsland’, ‘Zweden’)", connectie)

 Dim dtgoederen As DataSet = New DataSet
 dagoederen.Fill(dtgoederen, "Reports")
 connectie.Close()

 dggoederen.DataSource = dtgoederen.Tables("Reports")
End Sub
End Class
于 2013-11-11T08:28:31.990 回答