温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:汽车配件公司网站(VB.net+Access数据库)源码
当前文件:
VbNetCompany/top/modifile.aspx.vb,打开代码结构图
VbNetCompany/top/modifile.aspx.vb,打开代码结构图1Imports System 2
Imports System.Data 3
Imports System.Configuration 4
Imports System.Collections 5
Imports System.Web 6
Imports System.Web.Security 7
Imports System.Web.UI 8
Imports System.Web.UI.WebControls 9
Imports System.Web.UI.WebControls.WebParts 10
Imports System.Web.UI.HtmlControls 11
Imports System.Data.OleDb 12
13
Public Partial Class top_modifile 14
Inherits System.Web.UI.Page 15
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) 16
If Session("loginname") Is Nothing OrElse Session("loginname").ToString() = "" Then 17
Response.Write("<script>alert('用户登录时间超时,请重新登录');document.location='/admin.aspx'</script>") 18
Response.[End]() 19
End If 20
If Not Page.IsPostBack Then 21
If Request("id") IsNot Nothing AndAlso Request("id") <> "" Then 22
Using oleconn As New OleDbConnection() 23
oleconn.ConnectionString = ConfigurationManager.ConnectionStrings("oleConnectionString").ConnectionString 24
oleconn.Open() 25
Dim strSQL As String = "Select * From data where id=" + Request("id") 26
Dim command As New OleDbCommand(strSQL, oleconn) 27
Dim dataReader As OleDbDataReader = command.ExecuteReader() 28
If dataReader.Read() Then 29
titlename.Text = dataReader("name").ToString() 30
neirong.Text = dataReader("neirong").ToString() 31
End If 32
dataReader.Close() 33
oleconn.Close() 34
oleconn.Dispose() 35
End Using 36
End If 37
End If 38
End Sub 39
40
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) 41
If Session("loginname") Is Nothing OrElse Session("loginname").ToString() = "" Then 42
Response.Write("<script>alert('用户登录时间超时,请重新登录');document.location='/admin.aspx'</script>") 43
Response.[End]() 44
End If 45
Try 46
47
Using oleconn As New OleDbConnection() 48
oleconn.ConnectionString = ConfigurationManager.ConnectionStrings("oleConnectionString").ConnectionString 49
oleconn.Open() 50
51
Dim strSQL As String = "update [data] set [name]='" + titlename.Text + "',neirong='" + neirong.Text + "' where id=" + Request("id") 52
53
Dim command As New OleDbCommand(strSQL, oleconn) 54
command.ExecuteNonQuery() 55
56
oleconn.Close() 57
oleconn.Dispose() 58
Response.Write("<script language='javascript'>window.confirm('已经修改添加!!');</script>") 59
Response.Write("<script language='javascript'>document.location='add.aspx';</script>") 60
End Using 61
Catch err As Exception 62
Dim str As String = err.Message.Replace("'", "") 63
Response.Write("<script>alert('" + str + "');</script>") 64
End Try 65
End Sub 66
End Class






