create procedure [dbo].[CountPermits]
(
@CodeMelli nvarchar(50)
)
AS
BEGIN
select count(PermitType) as AllPermit from dbo.Permit where CodeMelli=@CodeMelli
select count(PermitType) as ColdPermit from dbo.Permit where CodeMelli=@CodeMelli and PermitType='01'
select count(PermitType) as HotPermit from dbo.Permit where CodeMelli=@CodeMelli and PermitType='10'
select count(ENDTik) as FinishPermit from dbo.Permit where CodeMelli=@CodeMelli and ENDTik like '%[1]%'
select count(ENDTik) as UnFinishPermit from dbo.Permit where CodeMelli=@CodeMelli and ENDTik='0000'
end
GO
Asked
Active
Viewed 37 times
0

Amit Verma
- 2,450
- 2
- 8
- 21

Abbas
- 1
- 2
-
Yes, You can fetch them in Dataset where it will give you an array of tables returned – Kovid Purohit Jul 09 '21 at 06:50
2 Answers
1
Yes, You can fetch multiple tables using a dataset where it will return an array of DataTables object.
The Same question has been answered over here

Kovid Purohit
- 258
- 1
- 4
- 15
-
ds is your dataset and when you do adapter.Fill(ds); it will fill your dataset with an array of tables which your Stored Procedure returns – Kovid Purohit Jul 12 '21 at 11:53
0
public IActionResult Index()
{
using (System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection("Connection"))
{
using (System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand())
{
cmd.CommandText = "dbo.CountPermits";
cmd.Connection = conn;
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@CodeMelli", codeMelli);
conn.Open();
System.Data.SqlClient.SqlDataAdapter adapter = new System.Data.SqlClient.SqlDataAdapter(cmd);
DataSet ds = new DataSet();
adapter.Fill(ds);
conn.Close();
}
}
return View(ds);
in cs.html you can use
@using System.Data
@model DataSet
@{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Index</title>
</head>
<body>
<table cellpadding="0" cellspacing="0">
<tr>
<th>AllPermit</th>
</tr>
@foreach (DataRow row in Model.Tables[0].Rows)
{
<tr>
<td>@row["AllPermit"]</td>
</tr>
}
</table>
<table cellpadding="0" cellspacing="0">
<tr>
<th>ColdPermit</th>
</tr>
@foreach (DataRow row in Model.Tables[1].Rows)
{
<tr>`enter code here`
<td>@row["ColdPermit"]</td>
</tr>
}
</table>
</body>
</html>

Manoj
- 36
- 2
-
Kindly add your own remaining part of code and proceed with your validation – Manoj Jul 09 '21 at 07:40
-
have checked and then placed the code. Kindly share your Control action and cs.html to check further please – Manoj Jul 10 '21 at 08:34