Query error

jeva39

Well-known member
Joined
Jan 28, 2005
Messages
135
Location
Panama
Programming Experience
1-3
I use this Query in a Access DataBase:

VB.NET:
[/color]
[/color][/size][/font][size=2][font=Verdana]dta = [/font][/size][font=Verdana][size=2][color=#0000ff]New[/color][/size][size=2]  OleDbDataAdapter("Select sum(saldo) as SALDOS from Clientes", con)

And I receive this error:

Syntax error (missing operator) in Query expression 'Sum(Saldo)'

The error is equal if I use CommandText or another thing
Please, what is the problem?

Thanks....
 
jmcilhinney:

GOAL!!!!!!! Your solution solve all the problem and the code work fine. Really thank you very much!!!! Only a last question: in a Module I have defined a Public Variablle to manage the result of SALDOS (Sum). Please, how I can do to assign this value to the variable?

kulrom:

I think you are wrong in your apreciation about me. I don't never ignore a person that help me or at least try to help me. Simply, jmcilhinney send me the correct solution. Believe me or not, I am very gratefull with you. Sorry if you think thus about me. But if you are angry or very angry with me, please ignore all my posts :)
 
kulrom:

Only now I have the time to see your examples in the Zips. Thanks!. A great help for me. I hope you now don't angry or at least less angry with me.. :)

Regards
 
You see ... i'm not angry i just want to help you but you ignored my posts with attached adequate solution for your problem ... that's it.
If you get second SUM.zip file you'll see that certain solution works as you wanted ... but i'm still wondering why you want to use datagrid for this purpose .... anyhow, i hope we'll have not misunderstods like this in the future ... Cheers :)
 
jeva39 said:
jmcilhinney:

GOAL!!!!!!! Your solution solve all the problem and the code work fine. Really thank you very much!!!! Only a last question: in a Module I have defined a Public Variablle to manage the result of SALDOS (Sum). Please, how I can do to assign this value to the variable?
If you just want to retrieve an aggregated value to a variable I would suggest using the ExecuteScalar() function of the OleDbCommand class like this:
VB.NET:
[color=Blue]Dim[/color] saldosSumCommand [color=Blue]As New[/color] OleDbCommand("SELECT SUM(saldo) FROM Clientes", con)
[color=Blue] Dim[/color] totalSaldos [color=Blue]As Integer[/color]

[color=Blue] Try[/color]
	con.Open()
	totalSaldos = saldosSumCommand.ExecuteScalar()
[color=Blue] Catch[/color]
	[color=Green]'...[/color]
[color=Blue] Finally[/color]
	con.Close()
[color=Blue] End Try[/color]
I hope this is helpful.
 
Really your solution in both Sums Zips are very good. Tomorrow I go to study my code and change somethings to Command and Datareader. I admit that I am a big fan of Datasets but allways exists a first time to change things in the life :)

Thanks again and please keep in mind that all your posts and the posts of all people that help me was very, very importants for me. This Forum is the best thing I find in the Net!!! But I have a relative difficult to express my ideas because my English is not THE BEST OF THE WORLD........:-(

Regards..
 
jeva39 said:
But I have a relative difficult to express my ideas because my English is not THE BEST OF THE WORLD........:-(

You think mine is good? Terrible if i may :( . But as long as we understand each
other the words that come out do not matter ... finally we need a code not only kind words ... hahaha ... Cheers :)
 
Back
Top