I know, but i have syntax errors, i use:
"SELECT * SUM(payed) from tbl_links where site='1'",
and get errors, i just couldn't find the right way...
|||Please post your table structure, some sample data and your SQL query and the error message. The more info you provide the better are the chances of receiving help and faster is the response time.|||
thaks for your reply's
the table structure:
columns:
ID, siteid (for the sending site), adid (the ad the user clicked), sum (the price we should pay to the site)
all columns are int's
the code line:
cmd.CommandText = "SELECT * SUM([sum]) FROM tbl_clicks WHERE siteid='" & sitename.SelectedItem.Value & "'"
and the error massege:
Incorrect syntax near 'SUM'
thanks for the help.
|||
(1) Your T-SQL is syntactically incorrect. you have to separate columns with a comma.
(2) You cannot use aggregate function with a "*". You need to list out the column names and use GROUP BY. Check out BOL for more info. If you simply want the sum you can do
SELECT SUM([sum]) FROM tbl_clicks WHERE siteid='" & sitename.SelectedItem.Value & "'"
(3) Use parameterized queries, without which your application is prone to SQL Injection attacks.
No comments:
Post a Comment