Solved

problem launching sql query from c#

Posted on 2011-09-08
3
199 Views
Last Modified: 2012-05-12
Hi experts,
I have the following error message
If this statement is a common table expression or an xmlnamespaces clause, the previous statement must be terminated with a semicolon
when i launch a query from my c# code. The same query works on sql server.
The query is
with a as (SELECT ROW_NUMBER()  OVER (ORDER BY xxx) AS num , * from dbo.xxx) select top (200) * from a as selezione
0
Comment
Question by:dionisio_79
  • 2
3 Comments
 
LVL 5

Accepted Solution

by:
zvytas earned 250 total points
ID: 36501185
Change the query to the following:

;
with a as (SELECT ROW_NUMBER()  OVER (ORDER BY xxx) AS num , * from dbo.xxx) select top (200) * from a as selezione

Note the semicolon at the beginning. WITH clause has to be either first statement in the batch OR you need a semicolon just before it.
0
 

Author Comment

by:dionisio_79
ID: 36501479
now I've got an incorrect sintax near ';'
incorrect sintax near ','
0
 
LVL 5

Expert Comment

by:zvytas
ID: 36501548
Show me your C# code you use to run the query.
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now