Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Data.SqlClient;
- using System.Linq;
- using System.Web;
- using System.Web.Configuration;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- namespace AndyProjectManagementSystem.Web
- {
- public partial class PMSPositionDemoPage : System.Web.UI.Page
- {
- private string _connStr = WebConfigurationManager.ConnectionStrings["AndyProjectManagementSystem"].ConnectionString;
- protected void Page_Load(object sender, EventArgs e)
- {
- ShowHaHaData();
- }
- public void TestConnection()
- {
- try
- {
- using (SqlConnection conn = new SqlConnection(_connStr))
- {
- conn.Open();
- Response.Write("資料庫連線成功");
- }
- }
- catch (Exception ex)
- {
- Response.Write("資料庫連線失敗");
- Response.Write("<br/>");
- Response.Write("<br/>");
- Response.Write(ex.ToString());
- }
- }
- public void ShowPMSPositionData()
- {
- DataTable dt = new DataTable();
- try
- {
- using (SqlConnection conn = new SqlConnection(_connStr))
- {
- string sql = "SELECT [Position_ID] ID, [Position], [Description] FROM [PMS_Position]";
- SqlCommand cmd = new SqlCommand(sql, conn);
- SqlDataAdapter da = new SqlDataAdapter(cmd);
- da.Fill(dt);
- }
- GridView1.DataSource = dt;
- GridView1.DataBind();
- }
- catch (Exception ex)
- {
- Response.Write("發生失敗");
- Response.Write("<br/>");
- Response.Write("<br/>");
- Response.Write(ex.ToString());
- }
- }
- public void ShowHaHaData()
- {
- string[] datas = new string[] { "Justin", "Andy", "Amy" };
- GridView2.DataSource = datas;
- GridView2.DataBind();
- }
- public void DateTypeConvert()
- {
- //string strNum = "5";
- //int intNum = strNum;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement