-
Notifications
You must be signed in to change notification settings - Fork 2
/
AssignAllStudentToLocalProject.aspx.cs
70 lines (59 loc) · 2.16 KB
/
AssignAllStudentToLocalProject.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Data;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Configuration;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace Lastellast
{
public partial class AssignAllStudentToLocalProject : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string connStr = WebConfigurationManager.ConnectionStrings["test"].ToString();
//create a new connection
SqlConnection conn = new SqlConnection(connStr);
SqlCommand assign = new SqlCommand("AssignAllStudentsToLocalProject", conn);
assign.CommandType = CommandType.StoredProcedure;
conn.Open();
assign.ExecuteNonQuery();
string sqlquery = "select * from [dbo].[Student]";
SqlCommand sulcomm = new SqlCommand(sqlquery, conn);
SqlDataAdapter sda = new SqlDataAdapter(sulcomm);
DataTable dt = new DataTable();
sda.Fill(dt);
StringBuilder sb = new StringBuilder();
sb.Append("<center>");
sb.Append("<tr>Student</tr>");
sb.Append("“<tr/>");
sb.Append("<table border=1>");
sb.Append("<tr>");
foreach (DataColumn dc in dt.Columns)
{
sb.Append("<th>");
sb.Append(dc.ColumnName.ToUpper());
sb.Append("</th>");
}
sb.Append("</tr>");
foreach (DataRow dr in dt.Rows)
{
sb.Append("</tr>");
foreach (DataColumn dc in dt.Columns)
{
sb.Append("“<th>");
sb.Append(dr[dc.ColumnName].ToString());
sb.Append("</th>");
}
sb.Append("</tr>");
}
sb.Append("</table>");
sb.Append("</center>");
Panel1.Controls.Add(new Label { Text = sb.ToString() });
conn.Close();
}
}
}