Transfering Data to Databases


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 8 of 8

Thread: Transfering Data to Databases

  1. #1
    Join Date
    Feb 2004
    Posts
    43

    Transfering Data to Databases

    I am using a DAO data control linking to an Access 2003 database. I have been extracting information already within the database using the following method:

    txtName.Text = datMembersDetails.Recordset("MembersForename")

    And this works fine. However it doesn't work the other way round:

    datMembersDetails.Recordset("MembersForename") = txtName.Text

    I am wanting to add data that the user has inputted into the text box into the table.

    I am using the add new command before this command e.g:

    datMembersDetails.Recordset.AddNew
    datMembersDetails.Recordset("MembersForename") = txtName.Text
    datMembersDetails.Recordset("MembersSurname") = txtName2.Text

    However this doesn't work. What am I doing wrong?

    Cheers
    Ryan

  2. #2
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    How are you creating the recordset?
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

  3. #3
    Join Date
    Feb 2004
    Posts
    43
    I have a data control with database set to my database location and recordsource set to a query in the database and that's it.

    Not sure exactly what you mean?

  4. #4
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    What's the query? What is the value of the data control's RecordsetType property?
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

  5. #5
    Join Date
    Feb 2004
    Posts
    43
    The query just pulls 5 fields from two tables, there are no expressions etc. And the RecordsetType is set to Dynaset I think.

  6. #6
    Join Date
    Dec 2003
    Posts
    2,750
    Don't you need to call the Update method:

    Code:
    datMembersDetails.Recordset.AddNew
    datMembersDetails.Recordset("MembersForename") = txtName.Text
    datMembersDetails.Recordset("MembersSurname") = txtName2.Text
    datMembersDetails.Recordset.Update
    Paul
    ~~~~
    Microsoft MVP (Visual Basic)

  7. #7
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    In addition to Paul's suggestion, if the query pulls data from more than one table in a "one-to-many" relationship, the recordset is not updateable.
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

  8. #8
    Join Date
    Feb 2004
    Posts
    43
    Cheers for the suggestions guys. Ended up finding a different solution that achieves the same results.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center