C # strongly typed dataset whose table adapter does not return the expected result

I have a C # application (using VS 2010 premium class) that implements a strongly typed dataset connected to an MS Access 2003 database. I am implementing a table adapter in this dataset, SQL script:

SELECT [ID], [Name], [Created By] FROM [Table Group] WHERE [Created By] = ? AND [ID] IN (SELECT [Group ID] FROM [Table Clustering] WHERE [Cluster ID] = ?) ORDER BY [Name] 
Problem

is that it does not return anything, but presumably it should (I have sample data in my database). I have already tried to implement the same script in MS Access (replacing? S with real data), and it returns the expected data.

I experimented by removing "WHERE [Cluster ID] = ?" into the built-in SELECT statement and returned the data, but this is not what I need.

I also did another experiment by replacing? inside the built-in SELECT statement with the actual [Cluster ID], and it returned the data, but again, that’s not what I need.

So what is the problem with the SQL script inside the table adapter? Is she able to implement SELECT in SELECT? moreover, is it capable of realizing? in SELECT in SELECT? as?

Thank you! =)

The strongly-typed dataset I was taking about

The SQL builder I am using to create the table adapter

as expected, the IDE automatically generates a method (to retrieve data) for the table adapter that I made, ergo I do not need to manually create an SQL script in the code ... for each information (in case you are "not familiar") generated the method asks for two parameters (as expected), one for [Created] and one for [Cluster ID] ... from here, please refer to my problem published above .: D

+4
source share
1 answer

I think this is an IDE bug. In particular, you have two parameters param1 and param2 in that order. You might think that "?" placeholders are in the same order, but when you execute the request and the IDE asks you to fill in the values, the last "?" is the first parameter (cluster identifier), and the first (CreatedBy) is the second parameter. This figure shows what I mean:

VS2012

In the image, the identifier is the first row and the Event Count is the second row, even if the TableAdaptor has them as the first number of events and the identifier of the second. I have not tried passing parameters through the program, but it seems like an error that the IDE will work this way.

0
source

All Articles