hacket
New member
- Joined
- Nov 5, 2008
- Messages
- 4
- Programming Experience
- 1-3
Hello,
I'm attempting to write data to an access database from a couple of text boxes on the form I'm working with. I get no errors, but the data doesn't appear in the database when I open it up. Anyone know what I'm missing here, because I'm using multiple examples of code that I've found.
Thank You.
I'm attempting to write data to an access database from a couple of text boxes on the form I'm working with. I get no errors, but the data doesn't appear in the database when I open it up. Anyone know what I'm missing here, because I'm using multiple examples of code that I've found.
VB.NET:
Dim command As New OleDbCommand
Dim connection As New OleDbConnection
connection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\RecipesDatabase.mdb"
command.CommandText = "INSERT INTO [Recipes] (Name, Ingredients) VALUES(@p1, @p2)"
command.Connection = connection
command.Parameters.Add("@p1", OleDbType.VarChar).Value = txtName.Text
command.Parameters.Add("@p2", OleDbType.VarChar).Value = txtIngredients.Text
connection.Open()
command.ExecuteNonQuery()
connection.Close()
Thank You.