Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load Dim objCon As SqlConnection Dim objCmd As SqlCommand Dim objDR As SqlDataReader Dim strDbCon, strSQL As String ' 資料庫連接字串 strDbCon = "Data Source=(LocalDB)\MSSQLLocalDB;" & "AttachDbFilename=" & Server.MapPath("App_Data\School.mdf") & ";Integrated Security=True" ' 建立Connection物件 objCon = New SqlConnection(strDbCon) objCon.Open() ' 開啟資料庫連接 strSQL = "SELECT * FROM Students" ' 建立Command物件的SQL指令 objCmd = New SqlCommand(strSQL, objCon) ' 取得DataReader物件 objDR = objCmd.ExecuteReader() If objDR.HasRows Then lblOutput.Text = "資料表記錄: