Click to See Complete Forum and Search --> : problem changing/saving with mysql
remcoploeg
August 16th, 2001, 06:21 AM
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
ploegr@promar-agencies.nl
Andrew_Fryer
August 16th, 2001, 06:54 AM
If you post your code I will have a look.
remcoploeg
August 16th, 2001, 07:01 AM
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
ploegr@promar-agencies.nl
Andrew_Fryer
August 16th, 2001, 07:04 AM
Does the Adoc1 variable have a requery method. If it does then use that.
remcoploeg
August 16th, 2001, 07:24 AM
what do you mean? Where can I set that?
Remco Ploeg
ploegr@promar-agencies.nl
Andrew_Fryer
August 16th, 2001, 07:28 AM
It would be along the lines of:
Adodc1.RecordSource = sSQL
Adodc1.Requery
That should fix it I think.
remcoploeg
August 16th, 2001, 08:26 AM
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
ploegr@promar-agencies.nl
hoa01206
August 16th, 2001, 10:01 AM
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
remcoploeg
August 17th, 2001, 01:47 AM
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
ploegr@promar-agencies.nl
hoa01206
August 17th, 2001, 11:14 AM
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
remcoploeg
August 19th, 2001, 09:45 AM
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
ploegr@promar-agencies.nl
Dazza
May 1st, 2002, 09:59 PM
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
Dazza
May 1st, 2002, 10:06 PM
fixed just used the new odbc driver
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.