Click here to Skip to main content
15,904,346 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Well, I'm stumped again. I am still working with an Access Database. I query thus;
SELECT [Item #], SUM(Amount)
FROM Ledger
GROUP BY [Item #]

It returns the Item #, but no values. Yet when I build the query and test it, it returns the proper values. Have no other SQL to try.
The query above is FillByItemTotal. And here is the VB code.

Private Sub cmdYTD_Click(sender As Object, e As EventArgs) Handles cmdYTD.Click
End Sub
I can't find anything wrong with either the query or the code.

I am filling a DataGridView that has only 2 columns. One for the item # and the second for the amount. The load works fine, populating the DataGridView with 153 items and each value. The vb code above is triggered with a button. When it runs, it populates the first column with 41 discreet items. The second column, (Amount), is empty. This whole project uses only two lines of code. Plus two queries. I might have to kick this project down the road.

What I have tried:

Tried several different queries. They work OK in Query Builder, But no values are returned when I run the form.
Updated 17-Dec-22 5:19am
Dave Kreskowiak 16-Dec-22 22:14pm    
Without seeing the code and some sample data, it's impossible to answer this.
Dave Kreskowiak 17-Dec-22 12:12pm    
TableAdapters... :sigh:.

Using the designers to do database work only hurts you. The designers hide the important details from you and makes it more difficult to debug and fix problems. Why? Because you don't know what the designers are doing, and more importantly, why they are doing the things they are.

When writing database code, I have NEVER used the designers and TableAdapters, and never will.

What you showed for code does not show the important parts that setup the adapter, or even the DataSet.
BobbyStrain 17-Dec-22 12:40pm    
Dave, Since this is such a tiny undertaking, I'll put it together with code, not the designer. Thanks.
BobbyStrain 20-Dec-22 17:55pm    
Dave, I want to report that I didn't relinquish use of the designer. That would require lot's of my time. Instead, I developed a workaround using VB code. Which was not easy for me because I had to deal with nulls in the database for the first time. But I learned a bit.

1 solution

We can't hep you directly - as you have been told before, we can't see your screen, access your HDD, or read your mind. And without seeing the non-working code and your actual data we can't even begin to guess what might be wrong.

So, it's going to be up to you.
Fortunately, you have a tool available to you which will help you find out what is going on: the debugger. If you don't know how to use it then a quick Google for "Visual Studio debugger" should give you the info you need.

Put a breakpoint on the first line in the function, and run your code through the debugger. Then look at your code, and at your data and work out what should happen manually. Then single step each line checking that what you expected to happen is exactly what did. When it isn't, that's when you have a problem, and you can back-track (or run it again and look more closely) to find out why.

I'm guessing that the code you think runs the same query as you did when it worked isn't the same, or you are doing something afterwards with the data that doesn't display the sum - but we can't see the code so we can't even begin to fix it!

Sorry, but we can't do that for you - time for you to learn a new (and very, very useful) skill: debugging!
Share this answer
BobbyStrain 17-Dec-22 11:22am    
Thanks, Griff. I'm first going to move the project to my laptop with a more recent version of VS and see how it behaves. Maybe kick this project down the road and just use Acces directly for this task.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900