저는 C#을 처음 사용합니다. Razor 뷰에 SQL을 어떻게 표시합니까?결과를보기로 가져 오는 방법
// GET: /ReportData
public ActionResult Index()
{
using (SqlConnection connection = new SqlConnection(@"Data Source=xxx.xxx.xxx.xxx;Initial Catalog=xxxxxx;Persist Security Info=True;User ID=xxxxx;Password=xxxxx"))
{
using (SqlCommand command = connection.CreateCommand())
{
command.CommandText = @"select * from ProjectManagement as p
join Implementation as i on p.JobNumber = i.JobNumber
join Divisions as d on i.Division = d.Division
where p.ProjectStatus = 'Active'"
connection.Open();
using (SqlDataReader reader = command.ExecuteReader())
{
while (reader.Read())
{
// process result
reader.GetValue(0);
reader.GetValue(1);
reader.GetValue(2);
reader.GetValue(3);
reader.GetValue(4);
reader.GetValue(5);
}
}
}
}
return View();
}
본인은 독자 객체에 따라 다르지만 이후에는 진행 방법에 대한 단서가 없습니다. 요점이 필요합니다 ...
처음 사용 더미 데이터가보기에 디스플레이된다. 그러면 SQL에서 결과를 얻고 그 결과를 표시하는 방법을 이해할 것입니다. – Haritha