CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 13 of 13
  1. #1
    Join Date
    Aug 2001
    Location
    The Netherlands, near germany
    Posts
    42

    problem changing/saving with mysql

    I have a problem, Im using vb with a mysql database. Now i made a form with several textboxen. Now I add for example NY to one box and I save it. It doesn't save. But when I remove a lite out the box, it saves.
    For example, textbox1 contains: hello how are you
    Now I want to add after hello how are you Remco?. Then I want to save, and vb doesn't save it to the database.
    Now, textbox1 contains: hello how are you
    Now i want to remove a few letters: how are you. (remove hello) Then I save it, and vb save it to the database. This is strange.
    I use a Update statement to save changes. But what goes wrong??

    Remco Ploeg
    [email protected]

  2. #2
    Join Date
    Aug 2000
    Location
    England
    Posts
    185

    Re: problem changing/saving with mysql

    If you post your code I will have a look.


  3. #3
    Join Date
    Aug 2001
    Location
    The Netherlands, near germany
    Posts
    42

    Re: problem changing/saving with mysql

    This is when I load the form:
    Private Sub Form_Load()
    Dim sSQL As String
    Dim tSQL As String
    Dim uSQL As String


    tSQL = "Select * from vis_tb_rep WHERE Company_ID = " & Vis_id
    Adodc2.CommandType = adCmdText
    Adodc2.RecordSource = tSQL
    Adodc2.Refresh
    uSQL = "Select * from bas_tb_object WHERE company_id OR relatie_id = " & Vis_id
    Adodc3.CommandType = adCmdText
    Adodc3.RecordSource = uSQL
    Adodc3.Refresh
    sSQL = "Select * from klantenbestand WHERE CompanyID = " & Vis_id
    Adodc1.CommandType = adCmdText
    Adodc1.RecordSource = sSQL
    Adodc1.Refresh
    End Sub

    Then to save (option 1):
    Private Sub Command3_Click()
    Dim nTemp As Integer, sTemp As String
    sTemp = "Are you sure you want to save?"
    nTemp = MsgBox(sTemp, vbYesNo, "Warning")
    If nTemp = vbYes Then
    Adodc1.Recordset.Update
    Adodc2.Recordset.Update
    Adodc1.Refresh
    Adodc2.Refresh
    End If
    End Sub

    Option (2):

    Dim sSQL as String
    sSQL ="UPDATE klantenbestand SET City = '" & txt4.Text & "' where object_id = " & Vis_id
    Adodc1.CommandType = adCmdText
    Adodc1.RecordSource = sSQL

    And that for every Item.

    Thanks




    Remco Ploeg
    [email protected]

  4. #4
    Join Date
    Aug 2000
    Location
    England
    Posts
    185

    Re: problem changing/saving with mysql

    Does the Adoc1 variable have a requery method. If it does then use that.


  5. #5
    Join Date
    Aug 2001
    Location
    The Netherlands, near germany
    Posts
    42

    Re: problem changing/saving with mysql

    what do you mean? Where can I set that?

    Remco Ploeg
    [email protected]

  6. #6
    Join Date
    Aug 2000
    Location
    England
    Posts
    185

    Re: problem changing/saving with mysql

    It would be along the lines of:

    Adodc1.RecordSource = sSQL
    Adodc1.Requery

    That should fix it I think.




  7. #7
    Join Date
    Aug 2001
    Location
    The Netherlands, near germany
    Posts
    42

    Re: problem changing/saving with mysql

    no, that is also not working. But the strangs thing is that I can remove letters, but when I add, it doesn't work!

    Remco Ploeg
    [email protected]

  8. #8
    Join Date
    Aug 2001
    Location
    PA
    Posts
    150

    Re: problem changing/saving with mysql

    Hello,

    before you update a record set, you want to define what you have done, either edit or addnew. In your case you are editing so you need

    Adodc1.Recordset.Edit before Adodc1.Recordset.Update

    So, add this line Adodc1.Recordset.Edit before Adodc1.Recordset.Update and try it. Good Luck!



    Thanks
    Hisham
    Thank You, Hisham

  9. #9
    Join Date
    Aug 2001
    Location
    The Netherlands, near germany
    Posts
    42

    Re: problem changing/saving with mysql

    If I put adodc1.recordset.edit (this one is not excisting on vb6 sp5) It gives adodc1.recordset.editmode. Then gives an error on running. Do I have the put the editmode in the same statement as adodc1.recordset.update or Do i have to put that in my formload?? And can I put that just like that, or do I have to put more??

    Remco Ploeg
    [email protected]

  10. #10
    Join Date
    Aug 2001
    Location
    PA
    Posts
    150

    Re: problem changing/saving with mysql


    Hello,

    After you add more to the box, in your click command that you save from add this line

    Adodc1.Recordset.Update
    Same way it is, do not worry about any extra arguments required. let me know if that will saves your stuff.




    Thanks
    Hisham
    Thank You, Hisham

  11. #11
    Join Date
    Aug 2001
    Location
    The Netherlands, near germany
    Posts
    42

    Re: problem changing/saving with mysql

    This is also not working. Now iám working with the normal data in vb, not anymore with Adodc. It still gives probelms and it wasn't reliable.

    thanks

    Remco Ploeg
    [email protected]

  12. #12
    Join Date
    Apr 1999
    Posts
    24

    Re: problem changing/saving with mysql

    i have the same problem same as you say but it only happens if there is only 1 record in the query. and i have tried it with a ado recordset every way i can think and using designer dataenviroment. the dataenviroment is the fastest but i still have the problem


  13. #13
    Join Date
    Apr 1999
    Posts
    24

    Re: problem changing/saving with mysql

    fixed just used the new odbc driver


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

Featured