First of all, your code is
SQL Injectioin[
^] vulnerable.
How to protect your site from SQL Injection attacks?
How To: Protect From SQL Injection in ASP.NET[
^]
Stop SQL Injection Attacks Before They Stop You[
^]
SQL Injection and how to avoid it[
^]
Dynamic SQL & SQL injection[
^]
Secondly, your insert statement is wrong, because you missed destination fields. Proper
insert
statement is:
INSERT INTO onlineUsers (Field1, Field2, Field3)
VALUES (val1, val2, val3)
Third of all, on
Page_Load event[
^] for
UserDefault.aspx
write code to get the count of logged users.
SQL query might look like:
SELECT COALESCE(COUNT(*),0) AS CountOfUsers
FROM onlineUsers
WHERE DateField BETWEEN DATEADD(dd, -1, GETDATE()) AND GETDATE()
For further information, please see:
Page Events[
^]
DATEADD[
^]
COALESCE[
^]
COUNT[
^]