form2-New user

Imports System.Data.OleDb
Public Class Form2
Inherits System.Windows.Forms.Form
Dim cn As OleDbConnection
Dim cmd As OleDbCommand
Dim dr As OleDbDataReader
Dim i, j, k, l As Integer
Dim a, b, c As String

#Region ” Windows Form Designer generated code ”

Public Sub New()
MyBase.New()

‘This call is required by the Windows Form Designer.
InitializeComponent()

‘Add any initialization after the InitializeComponent() call

End Sub

‘Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub

‘Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer

‘NOTE: The following procedure is required by the Windows Form Designer
‘It can be modified using the Windows Form Designer.
‘Do not modify it using the code editor.
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents Label3 As System.Windows.Forms.Label
Friend WithEvents TextBox2 As System.Windows.Forms.TextBox
Friend WithEvents Label4 As System.Windows.Forms.Label
Friend WithEvents TextBox3 As System.Windows.Forms.TextBox
Friend WithEvents Label5 As System.Windows.Forms.Label
Friend WithEvents TextBox4 As System.Windows.Forms.TextBox
Friend WithEvents Label6 As System.Windows.Forms.Label
Friend WithEvents TextBox5 As System.Windows.Forms.TextBox
Friend WithEvents Label7 As System.Windows.Forms.Label
Friend WithEvents TextBox6 As System.Windows.Forms.TextBox
Friend WithEvents Button1 As System.Windows.Forms.Button
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.Label1 = New System.Windows.Forms.Label
Me.TextBox1 = New System.Windows.Forms.TextBox
Me.Label2 = New System.Windows.Forms.Label
Me.Label3 = New System.Windows.Forms.Label
Me.TextBox2 = New System.Windows.Forms.TextBox
Me.Label4 = New System.Windows.Forms.Label
Me.TextBox3 = New System.Windows.Forms.TextBox
Me.Label5 = New System.Windows.Forms.Label
Me.TextBox4 = New System.Windows.Forms.TextBox
Me.Label6 = New System.Windows.Forms.Label
Me.TextBox5 = New System.Windows.Forms.TextBox
Me.Label7 = New System.Windows.Forms.Label
Me.TextBox6 = New System.Windows.Forms.TextBox
Me.Button1 = New System.Windows.Forms.Button
Me.SuspendLayout()

‘Label1

Me.Label1.Font = New System.Drawing.Font(“Microsoft Sans Serif”, 21.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label1.Location = New System.Drawing.Point(120, 16)
Me.Label1.Name = “Label1”
Me.Label1.Size = New System.Drawing.Size(200, 48)
Me.Label1.TabIndex = 2
Me.Label1.Text = “Assignment 4”

‘TextBox1

Me.TextBox1.Location = New System.Drawing.Point(216, 104)
Me.TextBox1.Name = “TextBox1”
Me.TextBox1.TabIndex = 3
Me.TextBox1.Text = “”

‘Label2

Me.Label2.Font = New System.Drawing.Font(“Microsoft Sans Serif”, 8.0!)
Me.Label2.Location = New System.Drawing.Point(80, 104)
Me.Label2.Name = “Label2”
Me.Label2.TabIndex = 4
Me.Label2.Text = “Name”

‘Label3

Me.Label3.Font = New System.Drawing.Font(“Microsoft Sans Serif”, 8.0!)
Me.Label3.Location = New System.Drawing.Point(80, 144)
Me.Label3.Name = “Label3”
Me.Label3.TabIndex = 6
Me.Label3.Text = “Username”

‘TextBox2

Me.TextBox2.Location = New System.Drawing.Point(216, 144)
Me.TextBox2.Name = “TextBox2”
Me.TextBox2.TabIndex = 5
Me.TextBox2.Text = “”

‘Label4

Me.Label4.Font = New System.Drawing.Font(“Microsoft Sans Serif”, 8.0!)
Me.Label4.Location = New System.Drawing.Point(80, 184)
Me.Label4.Name = “Label4”
Me.Label4.TabIndex = 8
Me.Label4.Text = “Password”

‘TextBox3

Me.TextBox3.Location = New System.Drawing.Point(216, 184)
Me.TextBox3.Name = “TextBox3”
Me.TextBox3.PasswordChar = Microsoft.VisualBasic.ChrW(120)
Me.TextBox3.TabIndex = 7
Me.TextBox3.Text = “”

‘Label5

Me.Label5.Font = New System.Drawing.Font(“Microsoft Sans Serif”, 8.0!)
Me.Label5.Location = New System.Drawing.Point(80, 224)
Me.Label5.Name = “Label5”
Me.Label5.TabIndex = 10
Me.Label5.Text = “Confirm password”

‘TextBox4

Me.TextBox4.Location = New System.Drawing.Point(216, 224)
Me.TextBox4.Name = “TextBox4”
Me.TextBox4.PasswordChar = Microsoft.VisualBasic.ChrW(120)
Me.TextBox4.TabIndex = 9
Me.TextBox4.Text = “”

‘Label6

Me.Label6.Font = New System.Drawing.Font(“Microsoft Sans Serif”, 8.0!)
Me.Label6.Location = New System.Drawing.Point(80, 264)
Me.Label6.Name = “Label6”
Me.Label6.TabIndex = 12
Me.Label6.Text = “Age”

‘TextBox5

Me.TextBox5.Location = New System.Drawing.Point(216, 264)
Me.TextBox5.Name = “TextBox5”
Me.TextBox5.TabIndex = 11
Me.TextBox5.Text = “”

‘Label7

Me.Label7.Font = New System.Drawing.Font(“Microsoft Sans Serif”, 8.0!)
Me.Label7.Location = New System.Drawing.Point(80, 304)
Me.Label7.Name = “Label7”
Me.Label7.TabIndex = 14
Me.Label7.Text = “Roll no:”

‘TextBox6

Me.TextBox6.Location = New System.Drawing.Point(216, 304)
Me.TextBox6.Name = “TextBox6”
Me.TextBox6.TabIndex = 13
Me.TextBox6.Text = “”

‘Button1

Me.Button1.Location = New System.Drawing.Point(144, 352)
Me.Button1.Name = “Button1”
Me.Button1.Size = New System.Drawing.Size(80, 32)
Me.Button1.TabIndex = 15
Me.Button1.Text = “Enter”

‘Form2

Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(448, 422)
Me.Controls.Add(Me.Button1)
Me.Controls.Add(Me.Label7)
Me.Controls.Add(Me.TextBox6)
Me.Controls.Add(Me.Label6)
Me.Controls.Add(Me.TextBox5)
Me.Controls.Add(Me.Label5)
Me.Controls.Add(Me.TextBox4)
Me.Controls.Add(Me.Label4)
Me.Controls.Add(Me.TextBox3)
Me.Controls.Add(Me.Label3)
Me.Controls.Add(Me.TextBox2)
Me.Controls.Add(Me.Label2)
Me.Controls.Add(Me.TextBox1)
Me.Controls.Add(Me.Label1)
Me.Name = “Form2”
Me.Text = “Form2”
Me.ResumeLayout(False)

End Sub

#End Region

Private Sub Form2_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
If TextBox3.Text = TextBox4.Text Then
cn = New OleDbConnection(“provider=microsoft.jet.oledb.4.0;data source=c:\a4.mdb”)
cn.Open()
cmd = New OleDbCommand(“select * from table1”, cn)
dr = cmd.ExecuteReader
While dr.Read()
If TextBox2.Text = dr(0) Then
l = 1
MsgBox(“The username already present. Try a different one”, MsgBoxStyle.Exclamation, “Error”)
TextBox2.Text = “”
TextBox3.Text = “”
TextBox4.Text = “”
Exit While
End If
End While
dr.Close()
cn.Close()

If l = 0 Then
cn = New OleDbConnection(“provider=microsoft.jet.oledb.4.0;data source=c:\a4.mdb”)
cn.Open()
cmd = New OleDbCommand(“insert into table1 values(‘” & TextBox2.Text & “‘,'” & TextBox3.Text & “‘,'” & TextBox6.Text & “‘,'” & TextBox1.Text & “‘,'” & TextBox5.Text & “‘)”, cn)
cmd.ExecuteNonQuery()
cn.Close()
MsgBox(“Record Added”)
Me.Close()
End If
Else
MsgBox(“Type username and password again”)
TextBox3.Text = “”
TextBox4.Text = “”

End If
l = 0

End Sub
End Class

Advertisements

One thought on “form2-New user

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s