Visual Studio SQL query not working [closed] - sql

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
I have a problem with a SQL query. The problem is with the IN ...., but I don't know how to correct it. This is the query:
SELECT *
FROM Reports, Games, Developers
WHERE Game = SpelID
AND Developer = IDDvl
AND Land IN[‘Japan’,‘USA’,‘UK’,‘Indië’,‘Duitsland’,‘Zweden’]
This is the error message:
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’]'.

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)
You need to replace [ ] with () after IN

Use right brackets and quotes:
SELECT *
FROM Reports , Games, Developers
WHERE Game = SpelID AND
Developer = IDDvl AND
Land IN ('Japan', 'USA', 'UK', 'Indië', 'Duitsland', 'Zweden')

replace with this code
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

The answer is specified in the error provided" In operator without () in query expression". Replace the "[]" with "()" for the IN T-SQL

Related

Send notifications in telegram group [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 4 months ago.
Improve this question
How can I have my telegramBot send automatically messages in a group?
def handle_event(event):
#print(event)
global amount0In
global amount1Out
global amount1In
global amount0Out
amount0In = event['args']['amount0In']
amount1Out = event['args']['amount1Out']
amount1In = event['args']['amount1In']
amount0Out = event['args']['amount0Out']
if amount0In and amount1Out != 0:
print(f"Token Sold {amount0In /10**18}, and eth {amount1Out/10**18}")
buy()
else:
print(f"Token Bought {amount0Out /10**18}, and eth {amount1In/10**18}")
sell()
def buy(update,context):
buyMessage = f"Buy!!!!\n💴: {amount1In/10**18}\nToken Bought: {amount0Out /10**18} \n"
update.message.reply_text(buyMessage)
def sell(update, context):
sellMessage = f"Sell!!!!\n💴: {amount1In/10**18}\nToken Sold: {amount0Out /10**18} \n"
update.message.reply_text(sellMessage)
In case the IF statement is met I want to send a message to a telgram group, however I cant execute the update message this way, because I keep getting this error:
TypeError: buy() missing 2 required positional arguments: 'update' and 'context'
How can I fix this?
To send a message, all you need is an instance of telegram.Bot. Please have a look at the introduction to the API for more details.
The functions buy and sell look like callback functions for handler. Since you are apparently not using python-telegram-bots handler setup to handle the event, there is no sense in defining those functions to accept the update and context arguments.
Disclaimer: I'm currently the maintainer of python-telegram-bot.

Why is my SQL Server CASE statement not working as expected [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 months ago.
Improve this question
I am trying to align these classifications using a CASE statement but the table build is still returning an incorrect value for the 3rd column in row 2 of the results (below). Can you help me figure out why? -- I'm really scratching my head here?
Code and screenshot below:
image highlighting the problem
SELECT DISTINCT
dom_id = 5,
stg1.PVDESC,
'bus_segment_test' =
CASE
WHEN stg1.PVDESC LIKE '%Process Monitoring%'
THEN stg1.PVDESC
ELSE 'Environmental Monitoring'
END,
comm_bus_segment_test =
CASE
WHEN 'bus_segment_test' LIKE '%Process Monitoring%'
THEN 'Process Monitoring'
ELSE 'Environmental Monitoring'
END
FROM
CDW_Staging.dbo.STG_1_ERP0005_BILL AS stg1
Row 2 in the following output table shows the undesired results (because incorrectly showing 'Environmental Monitoring' in Col3 when it should say 'Process Monitoring'):
dom_id
PVDESC
bus_segment_test
comm_bus_segment_test
5
BioAerosol
Environmental Monitoring
Environmental Monitoring
5
Process Monitoring
Process Monitoring
Environmental Monitoring
5
Franklin Systems
Environmental Monitoring
Environmental Monitoring
5
Franklin
Environmental Monitoring
Environmental Monitoring
5
West Columbia
Environmental Monitoring
Environmental Monitoring
5
Coal
Environmental Monitoring
Environmental Monitoring
Your second CASE statement is comparing the string 'bus_segment_test' to '%Process Monitoring%'. I'd change WHEN 'bus_segment_test' LIKE '%Process Monitoring%' THEN 'Process Monitoring' to WHEN stg1.PVDESC LIKE '%Process Monitoring%' THEN 'Process Monitoring'

"SELECT ##IDENTITY" throws overflow error

I am working on an MS Access solution where I need to insert a row and use its ID from within VBA. Thankfully, SQL gave us ##IDENTITY for exactly this purpose.
Or so I thought. In practice, it throws an overflow error. What can be possible causes of such an error?
Multiple Google searches could not come up with a solution.
Full line of code:
iid = CurrentDb.OpenRecordset("SELECT ##IDENTITY")(0)
German error message:
Laufzeitfehler '6': Überlauf
Translation:
Runtime Error '6': Overflow
Perhaps you need to declare iid as a 'variant' instead of an 'integer'?
http://www.dbforums.com/microsoft-access/1666779-any-idea-why-i-get-runtime-error-6-overflow.html

Error in unintuitive place reading in DataList [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
***ERROR***
***********
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
***********
Line: <td>< asp:Label ID="Label59" runat="server" Text='<%# Eval("field2").Equals("") ? "" : Eval("field3") + " " + Eval("field4") + " " + Eval("field 5") %>' /></td>
***********
***********
Hi,
Appreciate being able to get any feedback. I'm somewhat new to ASP.NET using 3.5
Getting error after adding a new field to an existing sqlreader class. The error is supposedly pointing to a null value in a datalist. But if this one line is removed there is no problem for the entire ItemTemplate.
_var= reader["field"] != null ? (int)reader["field"] : 0;
The only other change to the sqlreader class is the new field's get set.
Thank you in advance
If your field2 contains null, Eval("field2") will be null so you'll get a null-ref while calling Equals on it. Simply swap the operands:
<%# "".Equals(Eval("field2")) ? "" : Eval("field3") + " " + Eval("field4") + " " + Eval("field 5") %>
Although I'd recommend comparing with null which is more readable and likely more correct.

Apache Tomcat 5.5.23 error. HTTP Status 500 [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
Following is the stack trace
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: Unable to load class for JSP
org.apache.jasper.JspCompilationContext.load(jasper5-compiler-5.5.23.jar.so)
org.apache.jasper.servlet.JspServletWrapper.getServlet(jasper5-compiler-5.5.23.jar.so)
org.apache.jasper.servlet.JspServletWrapper.service(jasper5-compiler-5.5.23.jar.so)
org.apache.jasper.servlet.JspServlet.serviceJspFile(jasper5-compiler-5.5.23.jar.so)
org.apache.jasper.servlet.JspServlet.service(jasper5-compiler-5.5.23.jar.so)
javax.servlet.http.HttpServlet.service(tomcat5-servlet-2.4-api-5.5.23.jar.so)
looks like this code is compiled pre generics support,
An error occurred at line: 236 in the jsp file: /dashboard_new.jsp
Syntax error, parameterized types are only available if source level is 5.0
recompile the code with jdk >= 1.5 would be my guess or maybe the tomcat server is setup to use a jdk < 1.5
hope that helps
EDIT:
all of the errors apart from the one below seem to be a compiled version issue.
this one :
An error occurred at line: 338 in the jsp file: /dashboard_new.jsp
Incompatible conditional operand types String and int
335: out.println( "<td valign=\"top\">" + frameBean.getLatitude() + "</td>" );
336: out.println( "<td valign=\"top\">" + frameBean.getLongitude() + "</td>" );
seems to be trying to concatonate Strings and Integers. this should also work in later versions of java, i think.