July 26th, 2011, 10:17 PM
Items Not Adding to Database VS2010
I am trying to add items to my database. I can not seem to figure this out.
The code I have executes without errors, but the items just fail to appear in
the database. Please help! (and thanks in advance) The following is the only
code I have in my form. I have tried the SQL command with and without the ;
My form looks like this.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim Connection As New OleDb.OleDbConnection
Connection.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=Database2.accdb;"
Dim newrecord As New System.Data.OleDb.OleDbCommand 'declare the sql command
newrecord.CommandText = "INSERT INTO Users ([Email], [PWD], [FirstName], [LastName]) VALUES ('Reid', 'aa', 'bb', 'cc')" 'put together the command string
newrecord.Connection = Connection 'provide the newrecord with the connection info
Connection.Open() 'open the connection to to the database
newrecord.ExecuteNonQuery() 'execdute the command
Thank you for all your help!!!,
Tags for this Thread
Click Here to Expand Forum to Full Width
This a Codeguru.com survey!