Imports System.Data
Imports System.Data.OleDb
Partial Class Edite
Inherits System.Web.UI.Page
Dim objConn As New OleDbConnection
Dim objCmd As New OleDbCommand
Dim dtReader As OleDbDataReader
Dim strConnString, strSQL As String
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
strConnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("~/App_Data/mydatabase.mdb") & ";Jet OLEDB:Database Password=;"
objConn.ConnectionString = strConnString
objConn.Open()
If Not Page.IsPostBack() Then
ViewData()
End If
End Subds
Sub ViewData()
strSQL = "SELECT * FROM customer WHERE CustomerID = '" & Request.QueryString("CustomerID") & "' "
Me.lblStatus.Visible = True
Me.lblStatus.Text = "Text" & strSQL
Exit Sub
objCmd = New OleDbCommand(strSQL, objConn)
dtReader = objCmd.ExecuteReader()
If Not IsDBNull(dtReader.HasRows()) Then
Me.txtCustomerID.Text = dtReader.Item("CustomerID")
Me.txtName.Text = dtReader.Item("Name")
Me.txtEmail.Text = dtReader.Item("Email")
Me.txtCountryCode.Text = dtReader.Item("CountryCode")
Me.txtBudget.Text = dtReader.Item("Budget")
Me.txtUsed.Text = dtReader.Item("Used")
End If
dtReader.Close()
dtReader = Nothing
Sub Page_Load(sender As Object, e As EventArgs)
strConnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&Server.MapPath("database/mydatabase.mdb")&";Jet OLEDB:Database Password=;"
objConn.ConnectionString = strConnString
objConn.Open()
IF Not Page.IsPostBack() Then
ViewData()
End IF
End Sub
Sub ViewData()
'*** DataTable ***'
Dim dtAdapter As OleDbDataAdapter
Dim dt As New DataTable
strSQL = "SELECT * FROM customer WHERE CustomerID = '"& Request.QueryString("CustomerID") &"' "
dtAdapter = New OleDbDataAdapter(strSQL, objConn)
dtAdapter.Fill(dt)
If dt.Rows.Count > 0 Then
Me.txtCustomerID.Text = dt.Rows(0)("CustomerID")
Me.txtName.Text = dt.Rows(0)("Name")
Me.txtEmail.Text = dt.Rows(0)("Email")
Me.txtCountryCode.Text = dt.Rows(0)("CountryCode")
Me.txtBudget.Text = dt.Rows(0)("Budget")
Me.txtUsed.Text = dt.Rows(0)("Used")
End IF
End Sub