Dim UserName As String
Dim Passwordt As String
Dim SecurityQ As String
Dim SecurityAns As String
Passwordt = txtpass.Text
SecurityQ = CboSecurityQs.Text
SecurityAns = txtSecurityans.Text
cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Database genk.mdb;")
str = "INSERT INTO Users (FirstName, LastName, Username, Pword, Security_question, Security_answer ) values ('" & Firstname & "','" & Lastname & "','" & UserName & "','" & Passwordt & "','" & SecurityQ & "','" & SecurityAns & "')"
cmd = New OleDbCommand(str, cn)
Try
mes = cmd.ExecuteNonQuery
Catch ex As Exception
MsgBox(ex.ToString)
End Try
MessageBox.Show("User Added")
Dim value As String
Dim com2 As OleDbCommand = New OleDbCommand
com2.CommandText = "SELECT max(UserID) from Users where Username = '" & UserName & "'"
com2.Connection = cn
value = CType(com2.ExecuteScalar(), String)
cn.Close()
MsgBox("Your UserID is " & value, MsgBoxStyle.Information, "UserID")
Bascially i'm trying to output the userId of the client once they input their details and clicked the confrim button. I'm trying to execute the str string which will retrieve the userId from the client and pass it into the value variable to output it how ever i@m getting an error message of 'Conversion from type 'DBNull' to type 'String' is not valid' at : value = CType(com2.ExecuteScalar(), String) :s
could I get some help please
Thanks
Dim Passwordt As String
Dim SecurityQ As String
Dim SecurityAns As String
Passwordt = txtpass.Text
SecurityQ = CboSecurityQs.Text
SecurityAns = txtSecurityans.Text
cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Database genk.mdb;")
str = "INSERT INTO Users (FirstName, LastName, Username, Pword, Security_question, Security_answer ) values ('" & Firstname & "','" & Lastname & "','" & UserName & "','" & Passwordt & "','" & SecurityQ & "','" & SecurityAns & "')"
cmd = New OleDbCommand(str, cn)
Try
mes = cmd.ExecuteNonQuery
Catch ex As Exception
MsgBox(ex.ToString)
End Try
MessageBox.Show("User Added")
Dim value As String
Dim com2 As OleDbCommand = New OleDbCommand
com2.CommandText = "SELECT max(UserID) from Users where Username = '" & UserName & "'"
com2.Connection = cn
value = CType(com2.ExecuteScalar(), String)
cn.Close()
MsgBox("Your UserID is " & value, MsgBoxStyle.Information, "UserID")
Bascially i'm trying to output the userId of the client once they input their details and clicked the confrim button. I'm trying to execute the str string which will retrieve the userId from the client and pass it into the value variable to output it how ever i@m getting an error message of 'Conversion from type 'DBNull' to type 'String' is not valid' at : value = CType(com2.ExecuteScalar(), String) :s
could I get some help please
Thanks