1

I am trying to write a program in visual basic that reads and writes data by sending it to a MySQL server via PHP files on the server. When I was experimenting with the program on my local testing server, it worked wonderfully, but once I changed the URL variable from localhost to the server to which I am connecting, many bad things started happening. Among the problems that arose is that when you click the button to send the data to the database via the PHP file, this happens.

Clicking the button only executes one line of code --

webConnection.DownloadString(New Uri(url & "sendMessage&message=" & username & ": " & txtMessageToSend.Text))

I would appreciate it if someone explained how to resolve this issue. As a side question, is it possible for background workers to initialize class-level variables?

DaveTheMinion
  • 664
  • 3
  • 22
  • 45
  • possible duplicate of [WebClient does not support concurrent I/O operations.](http://stackoverflow.com/questions/13755623/webclient-does-not-support-concurrent-i-o-operations) – jdigital Dec 14 '13 at 02:06
  • @jdigital I saw the post that you are referring to, but I just ignored it because it is for C#. – DaveTheMinion Dec 14 '13 at 02:23
  • http://stackoverflow.com/questions/7931282/vb-using-downloadfileasync-webclient-for-multiple-downloads – Hackerman Dec 14 '13 at 02:33
  • @RobertRozas Thank you for the link. Since I cannot comment on other posts yet, I will ask here. One of the answers given says "I think is because of you using single WebClient instance to execute several HTTP requests at the same time. Try to use several instances." Is it possible that this has any relation to my problem? – DaveTheMinion Dec 14 '13 at 02:43
  • Yes, can you show me more of your vb code...and a piece of your php script...maybe that can give us some light in what is happening – Hackerman Dec 14 '13 at 02:47
  • @RobertRozas I'll gladly show some of the code, but there's a lot of it, so it may take some time for me to pull the important stuff out. – DaveTheMinion Dec 14 '13 at 03:07
  • Look, just maybe you are reusing the same client(webConnection) and that is the cause of your error....but you can use it one time, dispose it and create a new Dim client As WebClient = New WebClient() and use it to do the other request...sorry for my english, it's still terrible xD – Hackerman Dec 14 '13 at 03:12
  • @RobertRozas Thanks for the suggestion! Doing what you suggested warranted the results that I was looking for! – DaveTheMinion Dec 20 '13 at 02:19
  • No problem @DavidB ...i'm here to help ;) – Hackerman Dec 20 '13 at 02:24

0 Answers0