SQL = "SELECT SUM (Credits)[AmtPaid] from Table1 where date > dateadd(day,-385,getdate()) and customerid = '200'"
if AmtPaid > 100 then
response.Write "greater than 100"
else
response.Write "Amt is less than 100"
end if
This is the table view of the code:
It should say “greater than100”. not less than 100.
That is VB.Net code. There is no semicolon at the end and no parentheses around the condition (in the if statement) and you have “end if” at the end.
How do you execute the SQL? If that is all the code then you are not executing the SQL.
Are you using Visual Studio? If so then do you know how to use the debugger? Something easy to do is to use Debug.WriteLine to write data to the Output window. You need to learn how to set breakpoints so you can see what is actually happening. Note that to debug you might need to execute VS as an Administrator, but I might be wrong about use of the VS server. I have been using IIS for the server so I might have forgotten what happens when debugging using the VS server (I think it is IIS Express). You can use the debugger to confirm that the SQL does not have any affect on anything.
Also, I don’t know how VB.Net is converted to a link. I did not do that.
It is ASP code. You don’t need a semicolon or quotes around end if.
The code is executed on the server from the database.
Customerid paid 110 less than 90 days ago.
SQL = "SELECT case when SUM (Credits)>=110 then 'freegift' end as [AmtPaid] from Table1 where date > dateadd(day,-385,getdate()) and customerid = '1606'"
if AmtPaid = false then
response.Write "false"
end if
So the SQL Statement should be true but response.writes false regardless of the amount I use. So somewhere I am off on my statement. Just can’t figure it out.
ASP is not a language. I don’t know how to emphasize that except to say you will continue to fail if you think that ASP is a language. See If…Then…Else Statement (Visual Basic); it documents that VB.Net statement. It is VB.Net, not ASP!
I am asking how you execute the code on the server. What line of code are you using? I don’t know how to make that more clear except to say you will never execute SQL simply by putting SQL code in a variable called SQL.
If you can link to a Microsoft documentation page of the library you are using to execute the SQL then someone can help you with that. Otherwise we don’t know what to say. My suggestion is that you use Entity Framework as in Overview - EF6. It takes time to learn but it is the professional solution and will save time after you learn it. Entity Framework Overview appears to be a useful introduction too.
Perhaps if you told us what you are using to learn from then we can help you understand what you need to do.
I have 10 websites that run on asp. But I don’t know how to bring the asp code to the editor - very simple. I probably don’t have the expertise that you do. I am just looking for some help to coordinate the database field with the editor.
I don’t need the lectures from you!
Thanks, and I hope that I can gain some assistance. I mean well, not sure if you do!
I could help you but you seem to not want my help. You did not describe the problem very accurately or clearly and when I asked for clarification you replied as if you know more than I do. I had to lecture to get you to say:
That is much more useful. That is a problem that can be solved and needs to be solved.
I am not sure what:
means. I apologize for sounding arrogant but it was my hope you would describe the problem well enough to get help.
There are two problems here. One problem is how to edit the websites using Visual Studio. I assume you want to do that but you have not said so. The other problem is how to execute the SQL and get the results that you need. I think it would be better to create a new question for the first problem. For executing the SQL I think you still have not provided all the relevant code.