M4T VW
20-06-10, 17:56
Just having a play on writing stuff to a database like usernames and passwords etc but for some reason it wont save the info to a database!
My button info is:
Private Sub Button2_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
'Add Button
If TextBox1.Text = "" OrElse TextBox2.Text = "" Then
MsgBox("Please enter the complete name!", MsgBoxStyle.Exclamation + MsgBoxStyle.OkOnly, "Error")
Exit Sub
End If
con.Open()
Dim rs As New OleDb.OleDbCommand(
"INSERT INTO Users ([Username], [Password]) VALUES ('" &
StrConv(TextBox1.Text, VbStrConv.Uppercase) & "','" &
StrConv(TextBox2.Text, VbStrConv.Uppercase) & "','" &
StrConv(TextBox3.Text, VbStrConv.Uppercase) & "','" &
ComboBox1.Text & "'," &
Val(TextBox4.Text) & ")", con)
rs.ExecuteNonQuery()
con.Close()
LoadGrid("")
ClearText()
End Sub
But i get an "Insert into" error.
Ive put the username in square brackets because a read that the username is possibly a reserved field.
Any ideas on why it wont save to the database?
My button info is:
Private Sub Button2_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
'Add Button
If TextBox1.Text = "" OrElse TextBox2.Text = "" Then
MsgBox("Please enter the complete name!", MsgBoxStyle.Exclamation + MsgBoxStyle.OkOnly, "Error")
Exit Sub
End If
con.Open()
Dim rs As New OleDb.OleDbCommand(
"INSERT INTO Users ([Username], [Password]) VALUES ('" &
StrConv(TextBox1.Text, VbStrConv.Uppercase) & "','" &
StrConv(TextBox2.Text, VbStrConv.Uppercase) & "','" &
StrConv(TextBox3.Text, VbStrConv.Uppercase) & "','" &
ComboBox1.Text & "'," &
Val(TextBox4.Text) & ")", con)
rs.ExecuteNonQuery()
con.Close()
LoadGrid("")
ClearText()
End Sub
But i get an "Insert into" error.
Ive put the username in square brackets because a read that the username is possibly a reserved field.
Any ideas on why it wont save to the database?