简体   繁体   中英

c# strongly typed dataset whose table adapter is not returning expected result

I have a C# application (using VS 2010 premium) implementing a strongly-typed dataset that's connected to an MS Access 2003 database. I am implementing a table adapter within this dataset whose SQL script is:

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 it does not return anything but supposedly it should (I have sample data in my database). I already tried implementing the same script within MS Access (replacing the ?s with real data) and it returns the data I expect.

I experimented by removing "WHERE [Cluster ID] = ?" in the embedded SELECT statement, and it returned data but that's not what I need.

I also did another experiment by replacing the ? within the embedded SELECT statement with an actual [Cluster ID] and it returned data, but again that's not what I need.

So what's the problem of the SQL script within the table adapter? Is it capable of implementing a SELECT within a SELECT? moreover, is it capable of implementing a ? in a SELECT within a SELECT? how?

thank you! =)

我正在采用的强类型数据集

我用来创建表适配器的SQL构建器

so as expected, IDE automatically generates a method (to retrieve data) for the table adapter i did, ergo i do not need to manually create an SQL script within the code... for everyone's info (in case you're not familiar), the method generated asks for two parameters (as expected), one for [Created By] and one for [Cluster ID]... from here on, please refer to my problem i posted above. :D

I think this is an IDE bug. Specifically, you have two params so param1 and param2 in that order. You would think that the "?" placeholders are in the same order but when you execute the query and the IDE asks you to fill in values, the last "?" is the first param (Cluster ID) and the first one (CreatedBy) is the second param. This picture shows you what I mean:

VS2012

In the image, ID is the first line and Event Count is the second line even though the TableAdaptor has them as Event Count first and ID second. I didn't try passing the params via a program but it seems like a bug that the IDE would work this way.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM