Im trying to set up an application that will connect to a MYSQL database across the a distance using internet connection. i did it with VB 6 but it seems like the connection is not that stable and sometime it wont connect. Is it because of VB 6? would be better if i use Vb.net? Should i make always make the connection active or just disconnect it when there is no process? I know for sure that internet connection speed can greatly affect this process, can a VPN connection help? i hope someone could advise me on this..

Dani AI

Generated

— intermittent remote failures are almost always a network/hosting issue rather than a fault of VB6 itself. Moving to VB.NET helps because modern connectors and ADO.NET make error handling, connection pooling and disconnected work easier (as and suggested), but a language change alone will not cure high latency, packet loss, NAT/firewall drops, or server-side idle timeouts.

Best practice is to avoid opening client-to-DB connections across the public Internet. Place a small middle-tier service (HTTP/HTTPS API or web service) next to the MySQL server; clients call the API and the API talks to the DB. This centralizes security, retries, batching and reduces the number of long-lived sockets across unreliable links. If a direct DB connection is unavoidable, secure it (TLS/SSL), restrict allowed source IPs, use an SSH tunnel or VPN for access, and use a current connector (Connector/NET) with explicit timeouts.

Practical reliability tips: keep connections short-lived — open, do work, commit/rollback, close — and enable connection pooling so open/close cost is low; implement retry logic with exponential backoff for transient errors; use transactions for multi-statement updates and optimistic concurrency (row version/timestamp) so retries do not corrupt data. Watch MySQL server settings that close idle sessions (check wait_timeout/interactive_timeout) and DNS reverse-lookup delays — skip-name-resolve can help. Also increase command/connection timeouts only where appropriate and add detailed logging of SQL errors and network exceptions.

Checklist:

  • Verify network: ping/traceroute and check for packet loss and high latency.
  • Test from different networks and a simple MySQL client to isolate app vs network.
  • Use a middle-tier API where possible; otherwise secure the DB and restrict access.
  • Add retry/backoff and optimistic concurrency for updates.
  • Tune server wait_timeout or enable client keepalives; monitor logs for dropped connections.

These steps address the root causes more reliably than switching languages alone.

Recommended Answers

All 3 Replies

Well, one advantage you would have with .net would be the disconnected dataset architecture. You would open a connection get your dataset and then immediately close the connection and return your dataset. That way you don't have to worry about the internet connection being reliable.

ok... datasets can be set and close the connection? how about when i update the records?

In a disconnected artitechture provided by the ADO.Net will allow you connect to the database for all the DML,DDL and DQL statements. Once the results are acheved you can close the connection. The updated data will be stored in a local DataSet (DataSet follows the same artitechture as that of a database, so it'll contain all the tables there if you specify it in the query), you can modify the data there and then connect to the database and update the data and then close the connecton.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.