Imports System
Imports System.Data
Imports System.Configuration
Imports System.Collections
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Web.UI.HtmlControls
Imports System.Data.OleDb
Public Partial Class top_modifile
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
If Session("loginname") Is Nothing OrElse Session("loginname").ToString() = "" Then
Response.Write("<script>alert('用户登录时间超时,请重新登录');document.location='/admin.aspx'</script>")
Response.[End]()
End If
If Not Page.IsPostBack Then
If Request("id") IsNot Nothing AndAlso Request("id") <> "" Then
Using oleconn As New OleDbConnection()
oleconn.ConnectionString = ConfigurationManager.ConnectionStrings("oleConnectionString").ConnectionString
oleconn.Open()
Dim strSQL As String = "Select * From data where id=" + Request("id")
Dim command As New OleDbCommand(strSQL, oleconn)
Dim dataReader As OleDbDataReader = command.ExecuteReader()
If dataReader.Read() Then
titlename.Text = dataReader("name").ToString()
neirong.Text = dataReader("neirong").ToString()
End If
dataReader.Close()
oleconn.Close()
oleconn.Dispose()
End Using
End If
End If
End Sub
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs)
If Session("loginname") Is Nothing OrElse Session("loginname").ToString() = "" Then
Response.Write("<script>alert('用户登录时间超时,请重新登录');document.location='/admin.aspx'</script>")
Response.[End]()
End If
Try
Using oleconn As New OleDbConnection()
oleconn.ConnectionString = ConfigurationManager.ConnectionStrings("oleConnectionString").ConnectionString
oleconn.Open()
Dim strSQL As String = "update [data] set [name]='" + titlename.Text + "',neirong='" + neirong.Text + "' where id=" + Request("id")
Dim command As New OleDbCommand(strSQL, oleconn)
command.ExecuteNonQuery()
oleconn.Close()
oleconn.Dispose()
Response.Write("<script language='javascript'>window.confirm('已经修改添加!!');</script>")
Response.Write("<script language='javascript'>document.location='add.aspx';</script>")
End Using
Catch err As Exception
Dim str As String = err.Message.Replace("'", "")
Response.Write("<script>alert('" + str + "');</script>")
End Try
End Sub
End Class