Results 1 to 9 of 9

Thread: SQL.... UPDATE statment

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2000
    Location
    Ca
    Posts
    106

    Question

    view this codes and tell me what i did wrong. this update statement don't do anything


    Code:
    datGrouping.RecordSource = "UPDATE [Contacts] SET [Group] = '" & tempstring & "'"
    
    datGrouping.RecordSource = "SELECT * FROM [Contacts] ORDER BY CompanyName"
    
    datGrouping.Refresh

  2. #2
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Try using the Database.Execute method for 'action' queries.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  3. #3
    Frenzied Member
    Join Date
    Aug 1999
    Location
    Santa Clara, Ca , 95058
    Posts
    1,105
    Originally posted by xstopx81
    view this codes and tell me what i did wrong. this update statement don't do anything


    Code:
    datGrouping.RecordSource = "UPDATE [Contacts] SET [Group] = '" & tempstring & "'"
    
    datGrouping.RecordSource = "SELECT * FROM [Contacts] ORDER BY CompanyName"
    
    datGrouping.Refresh
    Easy. The second setting of datGrouping.RecordSource overwrites the first.

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Jul 2000
    Location
    Ca
    Posts
    106

    Unhappy

    thanks for replying guys but your suggestions are not working. I have used execute command and also tried deleting the select statment. Both method does not seem to work

  5. #5
    Hyperactive Member
    Join Date
    May 1999
    Location
    Reynosa, Mexico
    Posts
    274
    Maybe you forgot the WHERE statament in the first line. The statment as it appears will not know what rows to update. If you include a "WHERE [PrimaryKey]='SomeValue'", it could work.

    Good Look!

    [Edited by Tonatiuh on 08-18-2000 at 02:18 PM]
    Ulises Vázquez
    [size=1.7]Oracle DBA Certified Professioanl
    Visual Basic 6 Developer
    Crystal Reports Designer
    [/size]

  6. #6
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    If you leave out the WHERE clause, it updates all of them. Using the Execute method with an Update query worked for me.
    Try:
    Code:
    DB.Execute "UPDATE Contacts SET Group = '" & tempstring & "'"
    datGrouping.RecordSource = "SELECT * FROM Contacts ORDER BY CompanyName"
    datGrouping.Refresh
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Jul 2000
    Location
    Ca
    Posts
    106
    hey thanks for replying... parksie, in ur coding... what's DB? cant i just make it as datgrouping.database.execute? help

  8. #8
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    I just used DB as a placeholder for the original Database object.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  9. #9

    Thread Starter
    Lively Member
    Join Date
    Jul 2000
    Location
    Ca
    Posts
    106
    thanks parksie ... your coding works!!!

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