-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreport.aspx.cs
49 lines (45 loc) · 1.81 KB
/
report.aspx.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
using System;
using System.Data.SqlClient;
using System.Data;
using System.Configuration;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Microsoft.Reporting.WebForms;
namespace ASPWebApplication
{
public partial class report : System.Web.UI.Page
{
static string connectName = "MS:SQL2019 Bağlantısı"; //web.config dosyasında yer alan bağlantıya atanmış isim/name
static SqlConnection connect = new SqlConnection(ConfigurationManager.ConnectionStrings[connectName].ConnectionString);
static string query;
protected void Page_Load(object sender, EventArgs e)
{
if (Session["SessionID"] != null)
{
if(!this.IsPostBack)
{
query = "SELECT * FROM DBO_TestTable";
SqlCommand command = new SqlCommand(query, connect);
SqlDataAdapter adapter = new SqlDataAdapter(command);
DataSet dataSet = new DataSet();
adapter.Fill(dataSet, "DataSet1");
ReportViewer1.Reset();
ReportViewer1.LocalReport.ReportPath = Server.MapPath("~/Report1.rdlc");
ReportDataSource reportDS = new ReportDataSource("UsersTable", dataSet.Tables[0]);
ReportViewer1.LocalReport.DataSources.Clear();
ReportViewer1.LocalReport.DataSources.Add(reportDS);
ReportViewer1.LocalReport.Refresh();
}
}
else
{
login login = new login();
login.target = "report.aspx";
Response.Redirect("login.aspx");
}
}
}
}