我改好了,以下可以运行:
<%@ Page Language="VB" ContentType="text/html" Debug="true"%>
<%@ import namespace="system"%>
<%@ import namespace="system.data"%>
<%@ import namespace="system.data.sqlclient"%>
<script language="VB" runat="server">
sub page_load(sender as object,e as eventargs)
reg.visible=true
information.visible=false
end sub
sub retrieve()
dim myconnection as sqlconnection
myconnection=new sqlconnection("server=localhost;uid=sa;pwd=;database=lp")
myconnection.open()
dim adapter as sqldataAdapter
dim sqlstr as string
sqlstr="select * from message where id='"& username.text &"' and password='"& password.text & "'"
adapter=new sqldataadapter(sqlstr,myconnection)
dim DS as new dataset()
adapter.fill(DS,"info")
dim DT as datatable
DT=DS.tables("info")
if DT.rows.count=1 then
dim DV as dataview=DT.defaultview
display.datasource=dv
display.databind()
reg.visible=false
information.visible=true
else
response.Write("输入有误,请检查用户名和密码!")
end if
myconnection.close()
end sub
sub clickit(sender as object,e as eventargs)
retrieve()
end sub
sub datalist_itemcommand(sender as object,e as datalistcommandeventargs)
information.visible=true
reg.visible=false
select case e.commandsource.text
case "用户信息"
display.selectedindex=e.item.itemindex
retrieve()
case "关闭"
display.selectedindex=-1
retrieve()
case "修改信息"
display.editItemindex=e.Item.itemindex
retrieve()
case "取消"
display.edititemindex=-1
retrieve()
case "更新"
dim psd,repassword,ufond,grad,word as object
dim tbx as object
tbx=e.item.findcontrol("userfond")
ufond=tbx
tbx=e.item.findcontrol("gradu")
grad=tbx
tbx=e.item.findcontrol("userword")
word=tbx
tbx=e.item.findcontrol("pwd")
psd=tbx
tbx=e.item.findcontrol("repass")
repassword=tbx
if (psd.text<>repassword.text) then
response.Write("您两次输入的密码不相同,请从新输入。")
else
dim conn as sqlconnection
conn=new sqlconnection("server=localhost;uid=sa;pwd=;database=lp")
conn.open()
dim cmd as sqlcommand
dim sqlstr as string="update message set password='"& psd.text &"',fond='"& ufond.text &"',graduation='"& grad.text &"',leaveword='"& word.text &"' where id='"& username.text &"' and password='"& password.text &"'"
cmd=new sqlcommand(sqlstr,conn)
cmd.executenonquery()
response.Write("更新成功!")
try
catch exp as sqlexception
response.Write("更新失败!若需要更新,请从新开始。")
end try
conn.close()
display.edititemindex=-1
display.selectedindex=e.item.itemindex
end if
end select
end sub
</script>
看看这个问题:
<%@ Page Language="VB" ContentType="text/html"%>
<%@ import namespace="system"%>
<%@ import namespace="system.data"%>
<%@ import namespace="system.data.sqlclient"%>
<script language="VB" runat="server">
sub page_load(sender as object,e as eventargs)
reg.visible=true
information.visible=false
end sub
sub retrieve()
dim myconnection as sqlconnection
myconnection=new sqlconnection("server=localhost;uid=sa;pwd=;database=lp")
myconnection.open()
dim adapter as sqldataAdapter
dim sqlstr as string
sqlstr="select * from message where id='" & username.text & "' and password='" & password.text & "'"
adapter=new sqldataadapter(sqlstr,myconnection)
dim DS as new dataset()
adapter.fill(DS,"info")
dim DT as datatable
DT=DS.tables("info")
if DT.rows.count=1 then
dim DV as dataview=DT.defaultview
display.datasource=dv
display.databind()
reg.visible=false
information.visible=true
else
response.Write("输入有误,请检查用户名和密码!")
end if
myconnection.close()
end sub
sub clickit(sender as object,e as eventargs)
retrieve()
end sub
sub datalist_itemcommand(sender as object,e as datalistcommandeventargs)
information.visible=true
reg.visible=false
select case e.commandsource.text
case "用户信息"
display.selectedindex=e.item.itemindex
retrieve()
case "关闭"
display.selectedindex=-1
retrieve()
end select
end sub
</script>