01.
Imports
System.Data.OleDb
02.
Imports
System.Data
03.
Partial
Class
Default2
04.
Inherits
System.Web.UI.Page
05.
Dim
objConn
As
New
OleDbConnection
06.
Dim
objCmd
As
New
OleDbCommand
07.
Dim
dtReader
As
OleDbDataReader
08.
Dim
strConnString, strSQL
As
String
09.
10.
Protected
Sub
Page_Load(
ByVal
sender
As
Object
,
ByVal
e
As
System.EventArgs)
Handles
Me
.Load
11.
strConnString =
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source="
& Server.MapPath(
"~/App_Data/mydatabase.mdb"
) &
";Jet OLEDB:Database Password=;"
12.
objConn.ConnectionString = strConnString
13.
objConn.Open()
14.
15.
If
Not
Page.IsPostBack()
Then
16.
ViewData()
17.
End
If
18.
End
Sub
19.
20.
Sub
ViewData()
21.
strSQL =
""
& Request.QueryString(
"CustomerID"
) &
" "
22.
Me
.txtCustomerID.Visible =
True
23.
Me
.txtCustomerID.Text =
""
& strSQL
24.
Exit
Sub
25.
objCmd =
New
OleDbCommand(strSQL, objConn)
26.
dtReader = objCmd.ExecuteReader()
27.
28.
If
dtReader.HasRows
Then
29.
Me
.txtCustomerID.Text = dtReader.Item(
""
)
30.
Me
.txtName.Text = dtReader.Item(
"Name"
)
31.
Me
.txtEmail.Text = dtReader.Item(
"Email"
)
32.
Me
.txtCountryCode.Text = dtReader.Item(
"CountryCode"
)
33.
Me
.txtBudget.Text = dtReader.Item(
"Budget"
)
34.
Me
.txtUsed.Text = dtReader.Item(
"Used"
)
35.
End
If
36.
End
Sub
37.
38.
Sub
btnSave_Click(
ByVal
sender
As
Object
,
ByVal
e
As
EventArgs)
39.
40.
strSQL =
"UPDATE customer SET "
& _
41.
" CustomerID = '"
&
Me
.txtCustomerID.Text &
"' "
& _
42.
" ,Name = '"
&
Me
.txtName.Text &
"' "
& _
43.
" ,Email = '"
&
Me
.txtEmail.Text &
"' "
& _
44.
" ,CountryCode = '"
&
Me
.txtCountryCode.Text &
"' "
& _
45.
" ,Budget = '"
&
Me
.txtBudget.Text &
"' "
& _
46.
" ,Used = '"
&
Me
.txtUsed.Text &
"' "
& _
47.
" WHERE CustomerID = '"
& Request.QueryString(
"CustomerID"
) &
"' "
48.
49.
objCmd =
New
OleDbCommand
50.
With
objCmd
51.
.Connection = objConn
52.
.CommandText = strSQL
53.
.CommandType = CommandType.Text
54.
End
With
55.
56.
Me
.pnlAdd.Visible =
False
57.
Try
58.
objCmd.ExecuteNonQuery()
59.
Me
.lblStatus.Text =
"Record Updated"
60.
Me
.lblStatus.Visible =
True
61.
Catch
ex
As
Exception
62.
Me
.lblStatus.Text =
"Record can not update"
63.
End
Try
64.
65.
End
Sub
66.
67.
Sub
Page_UnLoad()
68.
objConn.Close()
69.
objConn =
Nothing
70.
End
Sub