sql data to asp:table in C# [closed] - c#

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I want that webpage connects to SQL database, and displays selected data in table. I have a query:
select top 5
r.remoteid,
count(distinct m.mac) as mac,
count(distinct i.igmp) as igmp,
i.date
from
remoteid as r
join
dbo.mac as m on m.mazgas = r.mazgas and m.portas = r.portas
join
dbo.igmp as i on i.mazgas = m.mazgas and i.portas = m.portas and i.date = m.date
where
i.date = DATEADD(day, datediff(day, 0, getdate()), -1)
group by
r.remoteid, r.mazgas, r.portas, m.vlan, m.date, i.date
order by
igmp desc
What is the best way to fill returned values to asp:table in HTML (<asp:Table ID="Table1" runat="server"></asp:Table>).
The table should look like this:
remoteid date
remote mac|igmp
Thank you.

<asp:Table> is not a data control. You have to use <asp:GridView>.

Related

Need Help Converting SQL Query to LINQ-to-SQL [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 days ago.
Improve this question
the query is:
SELECT DISTINCT TOP 10 COUNT( pp.Id), cd.Country,cd.State, pp.Id,cd.Email,CAST(pp.CreateDate AS DATE) AS paymentdate FROM Payments pp
JOIN cdTbl cd
ON pp.Id = cd.Id
WHERE pp.CreateDate IS NOT NULL AND CAST(pp.CreateDate AS DATE) = CAST(GETDATE() AS DATE)
GROUP BY pp.Id, cd.Email,CAST(pp.CreateDate AS DATE),cd.Country,cd.State
HAVING COUNT( pp.Id) > 1 AND cd.Email IS NOT NULL
ORDER BY CAST(pp.CreateDate AS DATE) DESC
Thanks

Filter database date in C# [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
In my database the date and time appear together with the data that was placed, but if I filter by date in C# as it has the time together I can't filter by date. Do I have to create a field for the date and another for the time?
...
WHERE med_date > '2021-06-08'
will get you all values that are after midnight at the start of today.
If you want to compute daily statistics then use CAST(... AS date) such as
SELECT CAST(med_date AS date) AS med_date, COUNT(*) AS n
FROM TheTable
GROUP BY CAST(med_date AS date)
ORDER BY 1
If you're using entity framework and LINQ to SQL queries, you can filter for date this way. Is that what you looking for?
dbcontext.DbSet<YouerEntity>.Where(x=>x.med_data.Date >= Date)

How can I implement SQL statement to LINQ in MVC? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
Good day
I need to interpret the following SQL to LINQ.
select
t1.req_no,
t1.seq_no,
t1.quantity,
t1.uom,
t1.item_name,
t2.event_date
from tb_cs_test t1, tb_cs_test2 t2 where (t1.req_no = 1 and t2.req_no = 1 );
I use MVC and with this SQL Statement i need to throw the requested fields based on the condition that I put
Thanks
You can do that with a JOIN:
from t1 in tb_cs_test
join t2 in tb_cs_test2
on t1.req_no equals t2.req_no
where t1.req_no = 1
select new {
t1.req_no,
t1.seq_no,
t1.quantity,
t1.uom,
t1.item_name,
t2.event_date
}

how to compare two different data table have same named column using loop in sql proceduer c#? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
i have 2 data table have same column and contain value.I want to compare data from both table and find the missmatching data in another table 2.Both table contain 38 column each.
Select
CASE WHEN t1.value = t2.value THEN 'True' ELSE 'False' END AS Result
From Table1 t1
Inner Join Table2 t2 on t1.ID = t2.ID

Outer apply in linq to sql [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
What's the linq to sql translation for this query
SELECT *
FROM MasterTable AS [t0]
Outer APPLY UfnGetDetail([t0].x, [t0].y, z) AS [t2]
...
Ok, it works with something like this
var query = from mt in db.MasterTable
let detailResult = db.UfnGetDetail(mt.x, mt.y, z).SingleOrDefault()...
Have you tried this:
from mt in dc.MasterTable
select dc.UfnGetDetail (mt.x, mt.y)

Categories