ramyar Posted October 25, 2002 Posted October 25, 2002 Hi, When I try to update the database table from the dataset table after inserting a new row in the dataset's datatable I get the following error ------------------------------------------ An unhandled exception of type 'System.InvalidOperationException' occurred in system.data.dll Additional information: The DataAdapter.SelectCommand property needs to be initialized. ------------------------------------------ at the line "adpProject.Update(dsProj, "Tasks")" But I have initialised the dataadapter's selectcommand property. cnPMS.Open() ' Create a SqlDataAdapter for the Project table. Dim adpProject As SqlDataAdapter = New SqlDataAdapter() ' A table mapping tells the adapter what to call the table. adpProject.TableMappings.Add("Table", "Tasks") Dim cmdProject As SqlCommand = _ New SqlCommand("SELECT * FROM Tasks", cnPMS) cmdProject.CommandType = CommandType.Text adpProject.SelectCommand = cmdProject adpProject.Fill(ds) 'BEGIN SEND CHANGES TO SQL SERVER Dim objCommandBuilder As New SqlCommandBuilder(adpProject) adpProject.Update(dsProj, "Tasks") ' END SEND CHANGES TO SQL SERVER Please Help. Thanks. Quote
*Experts* jfackler Posted October 30, 2003 *Experts* Posted October 30, 2003 The dataset you fill is created as ds. Your trying to update the db based on the dataset dsProj. Has that dataset been mapped for the dataadapter? I don't see any evidence of that occuring. ADO.net works differently than ADO. Check on the dataadapter as an example, it opens and closes the connection as neccessary. Delete the cnPMS.Open let the dataadapter.fill(dataset, "sourcetable"), and dataadapter.update(dataset, "sourcetable") do the opening and closing, it's more efficient. Jon Quote
robertsams23 Posted December 20, 2008 Posted December 20, 2008 a dataset tutorial , i think this will help you. http://vb.net-informations.com/dataadapter/dataAdapter-dataset.htm sams. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.