温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:汽车配件公司网站(VB.net+Access数据库)源码
当前文件:
VbNetCompany/top/add.aspx.vb,打开代码结构图
VbNetCompany/top/add.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
'5_1_a_s_p_x.c_o_m 13
14
Public Partial Class top_add 15
Inherits System.Web.UI.Page 16
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) 17
If Session("loginname") Is Nothing OrElse Session("loginname").ToString() = "" Then 18
Response.Write("<script>alert('用户登录时间超时,请重新登录');document.location='/admin.aspx'</script>") 19
Response.[End]() 20
End If 21
End Sub 22
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) 23
If Session("loginname") Is Nothing OrElse Session("loginname").ToString() = "" Then 24
Response.Write("<script>alert('用户登录时间超时,请重新登录');document.location='/admin.aspx'</script>") 25
Response.[End]() 26
End If 27
28
Try 29
Using oleconn As New OleDbConnection() 30
oleconn.ConnectionString = ConfigurationManager.ConnectionStrings("oleConnectionString").ConnectionString 31
oleconn.Open() 32
33
Dim strSQL As String = "Insert INTO data([name],neirong) Values('" + titlename.Text + "','" + neirong.Text + "')" 34
Dim command As New OleDbCommand(strSQL, oleconn) 35
command.ExecuteNonQuery() 36
37
oleconn.Close() 38
oleconn.Dispose() 39
Response.Write("<script language='javascript'>window.confirm('已经成功添加!!');</script>") 40
Response.Write("<script language='javascript'>document.location='add.aspx';</script>") 41
End Using 42
Catch err As Exception 43
Dim str As String = err.Message.Replace("'", "") 44
Response.Write("<script>alert('" + str + "');</script>") 45
End Try 46
End Sub 47
End Class






