|
-
August 16th, 2001, 06:21 AM
#1
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]
-
August 16th, 2001, 06:54 AM
#2
Re: problem changing/saving with mysql
If you post your code I will have a look.
-
August 16th, 2001, 07:01 AM
#3
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]
-
August 16th, 2001, 07:04 AM
#4
Re: problem changing/saving with mysql
Does the Adoc1 variable have a requery method. If it does then use that.
-
August 16th, 2001, 07:24 AM
#5
Re: problem changing/saving with mysql
what do you mean? Where can I set that?
Remco Ploeg
[email protected]
-
August 16th, 2001, 07:28 AM
#6
Re: problem changing/saving with mysql
It would be along the lines of:
Adodc1.RecordSource = sSQL
Adodc1.Requery
That should fix it I think.
-
August 16th, 2001, 08:26 AM
#7
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]
-
August 16th, 2001, 10:01 AM
#8
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
-
August 17th, 2001, 01:47 AM
#9
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]
-
August 17th, 2001, 11:14 AM
#10
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
-
August 19th, 2001, 09:45 AM
#11
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]
-
May 1st, 2002, 09:59 PM
#12
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
-
May 1st, 2002, 10:06 PM
#13
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|