Hey guys, got a new problem while trying to add a new user into the database.
After i've submitted all the data i get an error message saying "Conversion failed when converting the varchar value "Aron" to data type int"
to be honest, im totally stumped as to what this could meen, does it meen its trying to convert string type data to an integer?
Anyway heres the code im using
Code:Private Sub btnOk_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOk.Click 'Check all required fields are filled in If txtName.Text = "" Or txtPassword.Text = "" Or txtPassCheck.Text = "" Or txtPhone.Text = "" Then MessageBox.Show("Please fill in all required fields!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error) Exit Sub End If 'Before proceeding, check that both passwords match If txtPassCheck.Text <> txtPassword.Text Then MessageBox.Show("Your passwords do not match!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error) Exit Sub End If 'Before proceeding, check that phone number is numeric, if not exit sub If IsNumeric(txtPhone.Text) = False Then MessageBox.Show("Please enter only numbers!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error) txtPhone.Text = "" Exit Sub End If 'Declare variables Dim sUsername As String = txtName.Text Dim sPassword As String = txtPassword.Text 'Convert text box text to integer value Dim iPhone = CInt(txtPhone.Text) 'Open connection con.Open() 'Create new user Try CreateLogin.CommandText = ("INSERT INTO Users (UserID, Password, Phone) Values ('" & sUsername & "', '" & sPassword & "', '" & iPhone & "')") CreateLogin.ExecuteNonQuery() MessageBox.Show("New user created successfully!", "New User", MessageBoxButtons.OK, MessageBoxIcon.Information) Catch ex As Exception MessageBox.Show("Error occurred: " & ex.Message) End Try 'Close Connection con.Close() End Sub
Any help would be greatley appreciated!




Reply With Quote