| 发表于:2007-06-12 21:38:33 楼主 |
代码如下.. imports system.data imports system.data.sqlclient imports system.data.oledb public class editinfo inherits system.web.ui.page #region " web 窗体设计器生成的代码 " '该调用是 web 窗体设计器所必需的。 <system.diagnostics.debuggerstepthrough()> private sub initializecomponent() end sub protected withevents button1 as system.web.ui.webcontrols.button protected withevents dropdownlist1 as system.web.ui.webcontrols.dropdownlist protected withevents label1 as system.web.ui.webcontrols.label protected withevents textbox2 as system.web.ui.webcontrols.textbox protected withevents textbox3 as system.web.ui.webcontrols.textbox protected withevents textbox4 as system.web.ui.webcontrols.textbox protected withevents textbox6 as system.web.ui.webcontrols.textbox protected withevents textbox7 as system.web.ui.webcontrols.textbox protected withevents textbox8 as system.web.ui.webcontrols.textbox protected withevents label2 as system.web.ui.webcontrols.label protected withevents label3 as system.web.ui.webcontrols.label protected withevents label4 as system.web.ui.webcontrols.label protected withevents label6 as system.web.ui.webcontrols.label protected withevents label7 as system.web.ui.webcontrols.label protected withevents label8 as system.web.ui.webcontrols.label protected withevents label9 as system.web.ui.webcontrols.label protected withevents label10 as system.web.ui.webcontrols.label protected withevents form1 as system.web.ui.htmlcontrols.htmlform protected withevents textbox1 as system.web.ui.webcontrols.textbox '注意: 以下占位符声明是 web 窗体设计器所必需的。 '不要删除或移动它。 private designerplaceholderdeclaration as system.object private sub page_init(byval sender as system.object, byval e as system.eventargs) handles mybase.init 'codegen: 此方法调用是 web 窗体设计器所必需的 '不要使用代码编辑器修改它。 initializecomponent() end sub #end region private sub page_load(byval sender as system.object, byval e as system.eventargs) handles mybase.load '在此处放置初始化页的用户代码 dim sql as string sql = "select * from tableuserinfo where uid= " & trim(session( "user ")) dim connstr as string = "server=tse-d2b6bf793dd;uid=sa;pwd=;database=correspondence " dim myconn as new sqlconnection(connstr) dim da as new sqldataadapter(sql, myconn) dim ds as new dataset da.fill(ds, "tableuserinfo ") textbox1.text = ds.tables( "tableuserinfo ").rows(0)( "name ") textbox2.text = ds.tables( "tableuserinfo ").rows(0)( "email ") textbox3.text = ds.tables( "tableuserinfo ").rows(0)( "mobile ") textbox4.text = ds.tables( "tableuserinfo ").rows(0)( "uid ") textbox6.text = ds.tables( "tableuserinfo ").rows(0)( "address ") dropdownlist1.selecteditem.text = ds.tables( "tableuserinfo ").rows(0)( "gender ") textbox7.text = ds.tables( "tableuserinfo ").rows(0)( "postcode ") textbox8.text = ds.tables( "tableuserinfo ").rows(0)( "telephone ") end sub private sub button1_click(byval sender as system.object, byval e as system.eventargs) handles button1.click dim str as string ' dim passstr as string dim litem as listitem ' passstr = trim(cstr(text2.text)) ' passagin = trim(cstr(text3.text)) str = " ' " & textbox4.text & " ' " dim sql as string sql = "select * from tableuserinfo where uid= " & trim(session( "user ")) dim connstr as string = "server=tse-d2b6bf793dd;uid=sa;pwd=;database=correspondence " dim myconn as new sqlconnection(connstr) dim da as new sqldataadapter(sql, myconn) dim ds as new dataset da.fill(ds, "tableuserinfo ") dim dacomm as sqlclient.sqlcommandbuilder = new sqlclient.sqlcommandbuilder(da) ds.tables( "tableuserinfo ").rows(0)( "name ") = trim(textbox1.text) ds.tables( "tableuserinfo ").rows(0)( "email ") = trim(textbox2.text) ds.tables( "tableuserinfo ").rows(0)( "mobile ") = trim(textbox3.text) ds.tables( "tableuserinfo ").rows(0)( "uid ") = trim(textbox4.text) ds.tables( "tableuserinfo ").rows(0)( "address ") = trim(textbox6.text) ds.tables( "tableuserinfo ").rows(0)( "gender ") = trim(dropdownlist1.selecteditem.text) ds.tables( "tableuserinfo ").rows(0)( "postcode ") = trim(textbox7.text) ds.tables( "tableuserinfo ").rows(0)( "telephone ") = trim(textbox8.text) da.updatecommand = dacomm.getupdatecommand da.update(ds, "tableuserinfo ") session( "xstr ") = "用户修改成功 " response.redirect( "welcome.aspx ") end sub end class |
|
|
|
|