-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathBottom.aspx.vb
More file actions
49 lines (42 loc) · 1.95 KB
/
Bottom.aspx.vb
File metadata and controls
49 lines (42 loc) · 1.95 KB
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
Public Class Bottom
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
' Create a connection and open it.
Dim rootWebConfig As System.Configuration.Configuration
rootWebConfig = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("/")
Dim connString As System.Configuration.ConnectionStringSettings
connString = rootWebConfig.ConnectionStrings.ConnectionStrings("dbConnection")
Dim objConn As New System.Data.OleDb.OleDbConnection(connString.ToString)
objConn.Open()
Dim strSQL As String
Dim objDataset As New DataSet()
Dim objAdapter As New System.Data.OleDb.OleDbDataAdapter()
' Get all the customers from the USA.
strSQL = "Select * from customers where country='USA'"
objAdapter.SelectCommand = New System.Data.OleDb.OleDbCommand(strSQL, objConn)
' Fill the dataset.
objAdapter.Fill(objDataset)
' Create a new view.
Dim oView As New DataView(objDataset.Tables(0))
' Set up the data grid and bind the data.
DataGrid1.DataSource = oView
DataGrid1.DataBind()
' Verify if the page is to be displayed in Excel.
If Request.QueryString("bExcel") = "1" Then
' Set the content type to Excel.
Response.ContentType = "application/vnd.ms-excel"
' Remove the charset from the Content-Type header.
Response.Charset = ""
' Turn off the view state.
Me.EnableViewState = False
Dim tw As New System.IO.StringWriter()
Dim hw As New System.Web.UI.HtmlTextWriter(tw)
' Get the HTML for the control.
DataGrid1.RenderControl(hw)
' Write the HTML back to the browser.
Response.Write(tw.ToString())
' End the response.
Response.End()
End If
End Sub
End Class