TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Abdalla Omran
NA
334
32k
How could I filter Data based on URL or Date Time range ?
Feb 26 2020 2:25 PM
How could I filter Data based on URL or Date Time range or BOTH OF THEM ?
I am working with ASP.Net WebForms and i want to write only ONE query that do the following :
load all records after that i have comobox of URL and Date time Range from -to and i want to filter the records based on URL with datetime range or just based on datetime range without URL that's meaning when i load the whole data in GridView then i can filter them based on Datetime range and if the user want could filter the records based on (URL with Date Time range ) here what i tried and noted that i just want Query do all that :
1- load all record
2 - filter based on only date time range
3 - filter based on URL with Date Time range if the user want that
for any help i will be very glad
public
List<PageWebLog> GetPageWebLogs()
{
SqlCommand command =
new
SqlCommand();
if
(txtURL.Value ==
null
)
{
command.CommandText =
"SELECT URL, SearchEngine, COUNT(*) AS Anzahl FROM PagesLogs GROUP BY URL, SearchEngine HAVING(NOT(URL IS NULL))"
+
"ORDER BY Anzahl DESC"
;
}
else
{
command.CommandText =
"SELECT URL, SearchEngine, COUNT(*) AS Anzahl"
+
" FROM PagesLogs WHERE URL = @URL and(DateTime > CONVERT(DATETIME,@FromDate, 102)) AND(DateTime <= CONVERT(DATETIME, @ToDate, 102))"
+
" GROUP BY URL, SearchEngine HAVING(NOT(URL IS NULL)) ORDER BY Anzahl DESC"
;
command.Parameters.AddWithValue(
"@URL"
, txtURL.Value);
command.Parameters.AddWithValue(
"@FromDate"
, deStart.Value);
command.Parameters.AddWithValue(
"@Todate"
, deEnd.Value);
}
List<PageWebLog> elements =
new
List<PageWebLog>();
using
(SqlConnection connection = SqlHelper.getSQL_Connection(
true
))
{
connection.Open();
command.Connection = connection;
using
(SqlDataReader reader = command.ExecuteReader())
{
while
(reader.Read())
{
PageWebLog pagesLogs =
new
PageWebLog();
pagesLogs.URL = (
string
)reader[
"URL"
];
pagesLogs.SearchEngine = (
string
)reader[
"SearchEngine"
];
pagesLogs.Anzahl = (
int
)reader[
"Anzahl"
];
elements.Add(pagesLogs);
}
}
}
return
elements;
}
Reply
Answers (
1
)
prevent screen record,download and screencapture
Change Background color and text color dynamically.