Here is a little tutorial.
First setup your Database connection.
Put the next bit of code in your Form's Public class
Dim dbInsert As New OleDb.OleDbCommand Dim dbConnect As New OleDb.OleDbConnection
Put the next bit of code in your Form Load Private Sub
Try dbConnect.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source = C:\Database\Main.mdb" dbConnect.Open() Catch ex As Exception MessageBox.Show(ex.Message) Me.Close() End Try
Lets say you have 3 text boxes txtName, txtSurname & txtNumber and you want to update the database with the data in the boxes, put the following code in the update button click event Private Sub.
*NOTE: col_Name, col_Surname, col_Number are your column names in your database.
dbInsert.Parameters.Add(dbInsert.CreateParameter).ParameterName = "col_Name" dbInsert.Parameters.Item("col_Name").Value = txtName.Text dbInsert.Parameters.Add(dbInsert.CreateParameter).ParameterName = "col_Surname" dbInsert.Parameters.Item("col_Surname").Value = txtSurname.Text dbInsert.Parameters.Add(dbInsert.CreateParameter).ParameterName = "col_Number" dbInsert.Parameters.Item("col_Number").Value = txtNumber.Text
*NOTE: Table_Person is your table in the database.
dbInsert.CommandText = "INSERT INTO Table_Person VALUES (txtName.Text, txtSurname.Text, txtNumber.Text);" dbInsert.CommandType = CommandType.Text dbInsert.Connection = dbConnect dbInsert.ExecuteNonQuery() dbConnect.Close()
Edited 6 Years Ago by Animal Mother: n/a
i am using visual studio 2015 and trying to export data which i am importing through excel by the user selected Excel file. Now the importing part has been successfully completed i am using OLEDB Connection but Stuck in exporting the same data to a new Excel file. tried ...
I am creating a program that when you print an author, you must show all the information of all the books that the author has written. Add a new attribute in the Author class that will be "BooksWriting: List (Book)".
I have expanded the program so that it also ...
I am currently creating a simulation of a pizza ordering system in object oriented program. I have some question. the instruction and guideline is long but I will try and cut it down a lot. the instruction is to create a program that simulate a pizza restaurant using ...