Private  sub button1_click( )

Data Set

Dim ds as new dataset
Ds = new dataset(“student”)

Connectionstring

Dim connectionstring as string = “provider =Microsoft.jet.oledb.4.0;data source = student”;
Dim connection1 as oledb.oledbconnection = new oledb.oledbconnection(connectionstring)

Command object

Dim command1 as oledb.oledbcommand = new oledb.oledbcommand(“select * from student”)
Command1.commandtype = command.text
Connection1.open()
Comand1.connection = connection1

Data Adapter

Dim dataadapter1 as oledb.oledbdataadapter = new oledb.oledbdataadapter
 Dataadapter1.selectcommand=command1
Dataadapter1.tablemappings.add(“table’,”student”)
Dataadapter1.fill(ds)
Datagrid1.setbindings(ds,”table”)

Problem:----
Dear above code is used by me .in this code I have created dataset,command ,dataadapter,connection object’s.i have taken MS access database with vb.net 2005.this code only display record from database but when I want to add,delete,update record ‘It generate error that is a specific update,delete,insert command is required’ .so this is the main problem with me which leds frustrate me since last 6six month .i humbly request to all that if anybody can help me for this problem pls guide me with proper code of all with display record in texbox,combobox and Radiobutton.

1 I want ot insert new record in database.(In textbox,combobox,radiobutton)
2 I want to delete record from database(In textbox,combobox,radiobutton)
3 I want to update record . (In textbox,combobox,radiobutton)
PLEASE URGENT.

Dani AI

Generated

Quick diagnosis and a practical fix. The error reported by ("specific update,delete,insert command is required") means the DataAdapter only has a SelectCommand; Update needs either explicit Insert/Update/Delete commands or auto-generated ones. As noted, the adapter must have those commands. Two extra requirements often missed: the SELECT used to fill the DataTable must include the table’s primary key, and the DataTable must expose that primary key (otherwise row matching fails).

A short checklist to get Insert/Delete/Update working reliably:

  • Use a correct Access connection string (full .mdb/.accdb path; Jet for .mdb, ACE for .accdb).
  • SELECT the primary key column (e.g. StudentID) in the query used to fill the DataTable.
  • Either create an OleDbCommandBuilder for the data adapter (works for simple single-table SELECTs) or assign InsertCommand/UpdateCommand/DeleteCommand manually. For OleDb use positional ? parameters and add parameters in the same order.
  • Don’t call AcceptChanges() before DataAdapter.Update(...) — Update relies on RowState.
  • Bind controls to the DataTable (bind the table or a BindingSource, not the raw DataSet) so edits update the DataTable.

Example pattern (VB.NET):

Dim connStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\path\student.mdb;"
Dim da As New OleDbDataAdapter("SELECT StudentID, FullName, IsActive FROM student", conn)
Dim cb As New OleDbCommandBuilder(da)   ' generates Insert/Update/Delete
Dim ds As New DataSet()
da.Fill(ds, "student")

TextBoxName.DataBindings.Add("Text", ds.Tables("student"), "FullName")
ComboBox1.DataSource = ds.Tables("student")
ComboBox1.DisplayMember = "FullName"
ComboBox1.ValueMember = "StudentID"
RadioButton1.DataBindings.Add("Checked", ds.Tables("student"), "IsActive")

' After edits:
da.Update(ds, "student")

Troubleshooting notes: CommandBuilder cannot build commands for joined/complex SELECTs — use manual commands there. If updates still do nothing, verify the DataTable has a PrimaryKey set and rows show RowState = Modified/Added before calling Update. Also wrap any column names that contain spaces or reserved words in square brackets for Access.

Recommended Answers

All 2 Replies

If you have struggled for six months you cant have looked very far...the top result from my first google search returned this.

Hi , As you are specified command for filling datatable for the adapter, you have to specify for Insert (Dataadapter1.InsertCommand),update (Dataadapter1.UpdateCommand),Delete (Dataadapter1.DeleteCommand)command for that adapter also.

cheers
A Roy Chowdhury

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.