Code:
Dim insertCommand As New OleDbCommand("INSERT INTO tblCandidates (CandidateID, Name, Course, Address, CourseID) VALUES (?,?,?,?,?)", connection) If you are inserting a single row, use the first example and substitute the actual field values for the "?" symbols, using String.Format or by concatenating Strings. If you are inserting multiple rows that have already been added to a DataTable, use the second example and add parameters to the command, something like this:
Code:
insertCommand.Parameters.Add("CandidateID", OleDbType.Integer, 0, "CandidateID")
insertCommand.Parameters.Add("Name", OleDbType.VarWChar, 0, "Name")
insertCommand.Parameters.Add("Course", OleDbType.VarWChar, 0, "Course")
insertCommand.Parameters.Add("Address", OleDbType.VarWChar, 0, "Address")
insertCommand.Parameters.Add("CourseID", OleDbType.Integer, 0, "CourseID")
Bookmarks