ASP.NET user registration verification
Verify that the username is renowned in the registration database! ! ! Private Sub check_Click (ByVal sender As System.Object, ByVal e As System.EventArgs) Handles check.Click Dim myConnection As OleDbConnection Dim myCommand As OleDbCommand Dim dbname As String dbname = Server.MapPath ( "db1.mdb") myConnection = New OleDbConnection ("Provider = microsoft.jet.Oledb.4.0; data source = c: / documents and settings / administrator / my documents / Visual Studio Projects / WebApplication1 (2) /Database/db1.mdb") Database location
If UserId.Text = "" THEN Label5.text = "Error !! You Must Complete It" ELSE
DIM Checklogin As String Checklogin = "SELECT * from users"
DIM CMD AS New Oledbcommand (Checklogin, MyConnection) Dim Reader AS OledbDataReader
Try myconnection.open () reader = cmd.executeReader () reader.read ()
If UserId.Text = Reader ("UserID") THEN Label5.Text = "The userid Had been use" else label5.text = "this userid can use" end if catchool error (Err.MESSAGE) Label5. Text = "Checked Error" Finally if (Not MyConnection is Nothing) Then MyConnection.Close () endiff
END TRY END IF END SUB
Register Private Sub regist_Click (ByVal sender As System.Object, ByVal e As System.EventArgs) Handles regist.Click Dim myConnection As OleDbConnection Dim myCommand As OleDbCommand Dim dbname As String dbname = Server.MapPath ( "db1.mdb") myConnection = new OleDbConnection ( "PROVIDER = Microsoft.Jet.OLEDB.4.0; DATA Source = C: / Documents and Settings / Administrator / My Documents / Visual Studio Projects / WebApplication1 (2) /database/db1.mdb") Dim strinsert As String strinsert = "INSERT INTO Users (" Strinsert & = "U_ID, U_Password" "Strinsert & =" VALUES ('"Strinsert & = UserId.Text &",' "Strinsert & = Password.Text &" DIM CMD AS new OleDbCommand (strinsert, myConnection) Dim added As Integer Try myConnection.Open () added = cmd.ExecuteNonQuery If added> 0 Then Label5.Text = "your information is added" Response.Redirect ( "home.aspx") End If Catch Err As Exception Trace.write (Err.Message) Label5.Text = "Added Error" Finally if (not myconnection is nothing) Then MyConnection.Close () end if End Try
End Sub
/