ConnectionString 属性尚未初始化 急急急
Imports System.Data.OleDbPublic Class WebForm2
Inherits System.Web.UI.Page
#Region " Web 窗体设计器生成的代码 "
'该调用是 Web 窗体设计器所必需的。
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Protected WithEvents Label1 As System.Web.UI.WebControls.Label
Protected WithEvents TextBox1 As System.Web.UI.WebControls.TextBox
Protected WithEvents Label2 As System.Web.UI.WebControls.Label
Protected WithEvents TextBox2 As System.Web.UI.WebControls.TextBox
Protected WithEvents Label3 As System.Web.UI.WebControls.Label
Protected WithEvents Label4 As System.Web.UI.WebControls.Label
Protected WithEvents Label5 As System.Web.UI.WebControls.Label
Protected WithEvents TextBox3 As System.Web.UI.WebControls.TextBox
Protected WithEvents TextBox4 As System.Web.UI.WebControls.TextBox
Protected WithEvents TextBox5 As System.Web.UI.WebControls.TextBox
Protected WithEvents Button1 As System.Web.UI.WebControls.Button
'注意: 以下占位符声明是 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
'在此处放置初始化页的用户代码
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim objconn As OleDbConnection
objconn = New OleDbConnection
Dim objcmd As OleDbCommand
Dim strsql, strdsn As String
Dim userid1, pwd1, xm1, sex1, dep1 As String
userid1 = TextBox1.Text
pwd1 = TextBox2.Text
xm1 = TextBox3.Text
sex1 = TextBox4.Text
dep1 = TextBox5.Text
strdsn = "provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("library.mdb")
objconn = New OleDbConnection(strdsn)
If Not Check_BH(userid1) Then
strsql = "insert into reader values('" & userid1 & "','" & pwd1 & "','" & xm1 & "','" & sex1 & "','" & dep1 & "')"
objconn = New OleDbConnection(strdsn)
objcmd = New OleDbCommand(strsql, objconn)
objcmd.Connection.Open()
objcmd.ExecuteNonQuery()
objcmd.Connection.Close()
Response.Write("<script language='javascript'> alert('注册成功');</script>")
Else
Response.Write("<script language='javascript'> alert('注册不成功请重新输入');</script>")
End If
End Sub
Function Check_BH(ByVal bh As String) As Boolean
Dim objconn As New OleDbConnection
Dim strsql As String
Dim objdr As OleDbDataReader
Dim objcmd As OleDbCommand
strsql = "select * from reader where userid=' " & bh & " '"
objcmd = New OleDbCommand(strsql, objconn)
objcmd.Connection.Open()
objdr = objcmd.ExecuteReader()
Check_BH = False
While objdr.Read()
Check_BH = True
End While
End Function
End Class