Click here to Skip to main content
15,896,285 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
VB
Private Sub btSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btSubmit.Click
        Dim connection As New SqlClient.SqlConnection
        Dim command As New SqlClient.SqlCommand
        Dim adaptor As New SqlClient.SqlDataAdapter
        Dim dataset As New DataSet
        connection.ConnectionString = ("Data Source=.\CYRUS-PC\CYRUSSQL\Databases\USERS\Tables\dbo.Registration=|DataDirectory|\DataBase.mdf;Integrated Security=True;User Instance=True")
        command.CommandText = "INSERT INTO Registration Fname='" & txtFisrtName.Text & "' Lname='" & txtLastName.Text & "' Username='" & txtusername.Text & "'Gender='" & txtGender.Text & "' Password='" & txtPassword.Text & "';"
        connection.Open()
        command.Connection = connection
        adaptor.SelectCommand = command
        adaptor.Fill(dataset, "0")
        Dim count = dataset.Tables(0).Rows.Count
        If count > 0 Then
            MsgBox("registration succed", MsgBoxStyle.Information, "welcome to our system")
        Else
            MsgBox("registration failed", MsgBoxStyle.Exclamation, "try again")
            txtFisrtName.Clear()
            txtLastName.Clear()
            txtusername.Clear()
            txtGender.Clear()
            txtPassword.Clear()
        End If
    End Sub
End Class
Posted
Updated 15-Sep-14 1:01am
v2
Comments
[no name] 15-Sep-14 7:05am    
Did you have some sort of a question? Did you have some sort of a problem? Have you ever heard of an SQL injection attack?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900