Hello all,
I've been trying to achieve this one thing for ages now, and it's not happening.
My aim is to try to add a new user to a access database. Im doing this using from a form named frmRegister. It seems like the code is working perfectly, and i get no expections that indicate if any errors occured. However, the user doesn't get added to the database and it's causing me extreme headaches trying to figure out why.
The code i'm using is:
I have attached the project if you wish to look into this further.
(Files to large for attaching here)
Rar format - http://rapidshare.com/files/254374128/Files.rar.html
Zip format - http://rapidshare.com/files/254374401/Files.zip.html
I've been trying to achieve this one thing for ages now, and it's not happening.
My aim is to try to add a new user to a access database. Im doing this using from a form named frmRegister. It seems like the code is working perfectly, and i get no expections that indicate if any errors occured. However, the user doesn't get added to the database and it's causing me extreme headaches trying to figure out why.
The code i'm using is:
Code:
Public Class Register
Dim connectionString As String
Dim connection As OleDbConnection
Dim OLEDBAdapter As New OleDbDataAdapter
Dim OLE As String
Dim Username As String
Dim Password As String
Dim UserType As String
Private Sub Register_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\DataBase\UserInformation.mdb;Persist Security Info=False"
connection = New OleDbConnection(connectionString)
End Sub
Private Sub btnCreateAccount_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCreateAccount.Click
If mtbRegisterPassword.Text.Trim = mtbRegisterConfirmPassword.Text.Trim Then
Register()
Else
MsgBox("The password entered do not match.", MsgBoxStyle.Exclamation, "Oops!")
End If
End Sub
Function Register()
UserType = "Learner"
Username = txtRegisterUsername.Text.Trim
Password = mtbRegisterPassword.Text.Trim
Try
connection.Open()
OLE = "INSERT INTO tblUsers (UserName,UserPassword,UserType) VALUES(" + Username + ",'" + Password + "'," + UserType + ")"
OLEDBAdapter.InsertCommand = New OleDbCommand(OLE, connection)
MsgBox("Account Created")
Catch ex As Exception
MsgBox(ex.ToString)
End Try
connection.Close()
Return Nothing
End Function
End Class
I have attached the project if you wish to look into this further.
(Files to large for attaching here)
Rar format - http://rapidshare.com/files/254374128/Files.rar.html
Zip format - http://rapidshare.com/files/254374401/Files.zip.html