<!-My first ASP+Program->
<!-If there is a reprint, please indicate the source! Author: Nature Homepage: http://zhanzhen.wayAll.com Welcome
<!-The author wrote it blindly: Such a program took me N for a long time. Essence well. Essence The main reason is that I do n’t know much about ADO+. At first, in order to save system resources, I used DataReader. Later, I found that the original function was poor, so I switched to DataSET, alas. Essence After using the original ADO mode, it was really uncomfortable at once: (, and that VS7, although it is convenient to write ASP+, it seems to be easy to collapse, but it is a bit good to start the program immediately after the collapse. ) --->
<!-Program function: Use the Panel in ASP + Panel, the web control to achieve the switching of three windows, so that our plaintiff's function to implement with three pages in ASP (if it is hard to make a picture, it is okay, but but Don't be too complicated) Now you can finish it as long as one page. Then use ADO+DataSet and DataTable control to complete the operation of the database->
<!--
Preliminary work: Create a MyTest database in SQL Server, and then put this section in SQL Query Analyzer
create table [dbo]. [tb_user] (tb_user] (
[intid] [int] Identity (1, 1) not null,
[VCUserid] [varchar] (20) not null,
[vcpassword] [varchar] (20) not null,
[vcname] [varchar] (20) null,
[vctel] [varchar] (20) null,
[vcaddr] [varchar] (50) null
) On [primary]
GO
Then you can insert a few test data. I am also a novice of ASP +. I hope to learn from each other and improve it together :)
->
< %@ Import namespace = System.data.ado %>
< %@ Import namespace = System.data %>
<html>
<head>
<meta name = generator content = microsoft visual studio.net 7.0>
<meta name = code_language content = visual basic 7.0>
<Title> Modify Personal Basic Information </Title>
</head>
<body>
<FORM ID = PanelSC METHOD = Post Runat = Server>
<!-Log in the window->
<ASP: Panel ID = STEP1 Runat = Server>
Step 1: (Please enter the account and password) <p>
<blockquote>
Account number: <Asp: Textbox ID = Userid Runat = Server> </ASP: Textbox> <p>
Password: <Asp: Textbox ID = Password Runat = Server TextMode = Password> </ASP: Textbox> <p>
<input ID = Button1 Type = Button Value = Log in Runat = Server ONServerClick = Button1_Click> </P>
</blockquote>
<div ID = DIV1 RUNAT = Server> </DIV>
</asp: Panel>
<!-Modify the window->
<ASP: Panel ID = STEP2 Runat = Server>
Step 2: (Please modify the name, telephone, address) <p>
<blockquuote>
Name: <Asp: Textbox ID = name runat = server text => </asp: textbox> <p>
Tel: <Asp: Textbox ID = Tel Runat = Server Text => </ASP: Textbox> <p>
Address: <ASP: Textbox ID = ADDR Runat = Server Text => </ASP: Textbox> <p>
<input ID = Button2 Type = Button Value = Modify the Runat = Server ONServerClick = Button2_click>
</blockquote>
<div ID = DIV2 RUNAT = Server> </DIV>
</asp: Panel>
<!-Confirm window->
<ASP: Panel ID = STEP3 Runat = Server>
Step 3: (Please confirm the data you entered <p>
<blockquote>
<div ID = DIV3 RUNAT = Server> </DIV>
<input ID = Button3 Type = Button Value = OK Runat = Server ONServerClick = Button3_Click>
</blockquote>
</asp: Panel>
<!-Successful window->
<ASP: Panel ID = STEP4 Runat = Server>
<blockquote>
<div ID = DIV4 RUNAT = Server> </DIV>
</blockquote>
</asp: Panel>
</form>
</body>
</html>
<script language = vb runat = server>
sub page_load (SENDER As Object, E as eventArgs)
if not page.ispostback then
step1.visible = true
step2.visible = false
step3.visible = false
end if
end sub
sub button1_click (Sender as object, E as eventArgs)
dim connstr, sqlquery as string
DIM I as Integer = 0
connstr = driver = {sql server}; server = localhost; uID = SA; pwd =; database = mytest
sqlquery = select vcname, VCTEL, VCADDR from TB_USER WHERE VCUserid = '& Userid.text &' And vcpassword = '& Password.text &'
DIM CMD As Adodatasetcommand = New AdodatasetCommand (SQLQUERY, Connstr)
DIM RS As dataset = New DataSet ()
cmd.filldataset (RS, TB_USER)
dim dt as datatable = rs.tables (tb_user)
I = dt.Rows.Count
if i = 1 THEN
name.text = dt.rows (0) .Item (0)
tel.Text = dt.rows (0) .Item (1)
addr.Text = dt.rows (0) .Item (2)
step1.visible = false
step2.visible = true
step3.visible = false
else
step1.visible = true
step2.visible = false
step3.visible = false
div1.innerhtml = Log in failed! Please check whether your account and password are correct!
end if
end sub
sub button2_click (Sender as object, E as eventArgs)
step1.visible = false
step2.visible = false
step3.visible = true
div3.innerhtml = account number: & userid.text & <br>
div3.innerhtml & = Name: & name.text & <br>
div3.innerhtml & = Tel: & TEL.Text & <br>
div3.innerhtml & = Address: & addr.text & <p>
end sub
sub button3_click (Sender as object, E as eventArgs)
dim connstr, sqlquery as string
connstr = driver = {sql server}; server = localhost; uID = SA; pwd =; database = mytest
sqlquery = update TB_USER SET VCNAME = '& Name.text &', VCTEL = '& TEL.Text &', VCADDR = '& Addr.text &'
dim cmd as adocommand = New Adocommand (SQLQuery, Connstr)
cmd.activeConnection.open ()
cmd.execute ()
if cmd.Recordsaffected = 1 then
div4.innerhtml = Your profile has been correctly modified! <A href = Panelsc.aspx> Return to log in </a>
else
div4.innerhtml = errors occur! <A href = javascript: hestory.back (-1)> Back this back to revise </a>
end if
end sub
</script>