Results 1 to 3 of 3

Thread: Adding to a Database with a Data Grid

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2003
    Location
    Chicago, Illinois
    Posts
    9

    Adding to a Database with a Data Grid

    Greets fellow nerds,
    this post concerns VB.Net.
    I'm writing a program that uses Parent and Child data grids. This program reads from a database and displays the data in the data rows as planned. When I highlight a row in the parent grid, the related date displays in the child grid as planned. I need to add, modify, and delete data from thr database with this program.

    My prob is that I can't add a new record of data in the parent grid. I get an error and the debugger stops. I can add a new row of data in the child grid and save it with no problems.

    Have any of you guys had this prob? How do I get the Parent to accept new data and transfer it to the database?

    I attached the code for this, see the code. Open the rtf text file with Wordpad.


    Thanx a mil,
    LFJ
    Attached Files Attached Files
    I am the Code King

  2. #2

    Thread Starter
    New Member
    Join Date
    Mar 2003
    Location
    Chicago, Illinois
    Posts
    9
    Please reply to this post. Toss in you $0.02. Don't be bashful. I need the help. You cats can help me, I'm sure of this. So, go ahead and get your feet wet. Give it a try, jump right in!
    I am the Code King

  3. #3
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    See if this would do the trick !

    VB Code:
    1. 'get data from datagrid and store them in obj
    2. Dim obj As New Object()
    3. obj = DataGrid1.DataSource
    4.  
    5.  
    6. 'pass the obj array to the datarow.itemarray and then update yourdatabase
    7. Dim datarow As DataRow
    8. datarow.ItemArray = obj

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width