简体   繁体   中英

DataAdapter.Fill method TWO tables in query

This may seem simple, but I'm having difficulty figuring out how to fill my dataset when my query includes more than one table.

For example, if I had a query that was "SELECT USER_ID, USER_NAME, CREDENTIALS FROM USERS, CREDENTIALS WHERE USER_ID = CRED_ID" and then try to use the DataAdapter.Fill method it throws and error saying it's not a single group function.

My DataAdapter is = da
My DataSet is = ds

What I'm trying is:

da.Fill(ds, "USERS;CREDENTIALS"); 

or

da.Fill(ds, "USERS, CREDENTIALS");

How would I go about doing this correctly? I just need to run a query that selects from 2 tables based on a matching ID, but I'd like it in a single Dataset so I can go through the results 1 row & column at a time.

Any help is GREATLY appreciated!

I'm confused. The result you are getting back is a single "table". You are doing a join between two tables, sure, but you are not actually returning two tables. Is there something I am missing?

Problem solved. I had a MAX function being performed in my query and I did not have all SELECT fields listed in the GROUP BY clause.

Added those fields and got it working.

Thanks to all!

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