Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Problems updating a dataset

Problems updating a dataset

Scheduled Pinned Locked Moved Database
helpannouncementdatabasesqlite
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    newbjohny
    wrote on last edited by
    #1

    Hi, I am having trouble in updating my dataset, I create a dataset from a select command and display the details to a datagrid. I then goto the next new line in the datagrid and insert some new details then click the insertRow button (code below) and I get the following error message :- the exception which is caught states : - "Value cannot be null. Parameter name: dataset" I am not up to scratch with datasets, but all examples I can find of updates are where only one line of the dataset is shown at a time in text boxes and then a blank set of textboxes are displayed to add a new row then convert the textboxes.text to the add row command, but I am creating an application to be a front end to a database so none of the columns are known so I cannot create this form of input as the amount of textboxes would never be known. Please help Many thanks John Code for updating dataset [CODE] Private Sub btnInsertRow_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnInsertRow.Click Dim dset As DataSet tblName = (cmbInsertData.Text) dbConn.openExistingDatabse("Data Source=" & getDBName() & ";Version=3;New=False;Compress=True;") dbConn.createSQLCommand() Try dbConn.updateDataSet(dset, tblName) Catch es As Exception MessageBox.Show(es.Message) End Try End Sub[/CODE] [CODE] Public Sub updateDataSet(ByVal dset As DataSet, ByVal tableName As String) Dim sqlite_dataAdapter As SQLiteDataAdapter = New SQLiteDataAdapter() sqlite_commandBuilder = New SQLiteCommandBuilder(sqlite_dataAdapter) sqlite_dataAdapter.Update(dset, tableName) End Sub[/CODE]

    P 1 Reply Last reply
    0
    • N newbjohny

      Hi, I am having trouble in updating my dataset, I create a dataset from a select command and display the details to a datagrid. I then goto the next new line in the datagrid and insert some new details then click the insertRow button (code below) and I get the following error message :- the exception which is caught states : - "Value cannot be null. Parameter name: dataset" I am not up to scratch with datasets, but all examples I can find of updates are where only one line of the dataset is shown at a time in text boxes and then a blank set of textboxes are displayed to add a new row then convert the textboxes.text to the add row command, but I am creating an application to be a front end to a database so none of the columns are known so I cannot create this form of input as the amount of textboxes would never be known. Please help Many thanks John Code for updating dataset [CODE] Private Sub btnInsertRow_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnInsertRow.Click Dim dset As DataSet tblName = (cmbInsertData.Text) dbConn.openExistingDatabse("Data Source=" & getDBName() & ";Version=3;New=False;Compress=True;") dbConn.createSQLCommand() Try dbConn.updateDataSet(dset, tblName) Catch es As Exception MessageBox.Show(es.Message) End Try End Sub[/CODE] [CODE] Public Sub updateDataSet(ByVal dset As DataSet, ByVal tableName As String) Dim sqlite_dataAdapter As SQLiteDataAdapter = New SQLiteDataAdapter() sqlite_commandBuilder = New SQLiteCommandBuilder(sqlite_dataAdapter) sqlite_dataAdapter.Update(dset, tableName) End Sub[/CODE]

      P Offline
      P Offline
      Paul Brower
      wrote on last edited by
      #2

      You could try disabling the constraints on your dataset (temporarily). DataSet.EnforceConstraints = false ; Usually I like to create a new DataRow, and populate it with default values, and then insert the DataRow into the appropriate DataTable. If your grid is bound to the DataSet, then the new row will automatically appear in the grid.

      N 1 Reply Last reply
      0
      • P Paul Brower

        You could try disabling the constraints on your dataset (temporarily). DataSet.EnforceConstraints = false ; Usually I like to create a new DataRow, and populate it with default values, and then insert the DataRow into the appropriate DataTable. If your grid is bound to the DataSet, then the new row will automatically appear in the grid.

        N Offline
        N Offline
        newbjohny
        wrote on last edited by
        #3

        Hi, thanks foryour advice, I havesince managed to get the dataset working. Many thanks John

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups