2 Replies - 363 Views - Last Post: 29 October 2019 - 09:15 AM Rate Topic: -----

#1 GHviru5   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 28-October 19

mysql connection problem

Posted 28 October 2019 - 04:49 AM

hi everyone, i have a problem when connecting to a MySQL database on a different PC on the same LAN. when i connect to the server on the local PC i don't encounter any problem but wen i try to connect to the database on a different PC on the same LAN i get an error saying "Object reference not set to an instance of an object." here is the codes am using.


Imports MySql.Data.MySqlClient
Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim Connection As New MySqlConnection("server=192.168.1.2;port=3306; user id=root; password=; database=salesDepo")
        Connection.Open()
        Dim Command As New MySqlCommand("insert into BusketTable (item,unitPrice,Quantity,ItemTotal,DrugId) Values('10','30','7','yo','to')", Connection)
        Command.ExecuteNonQuery()
        Connection.Close()

    End Sub
End Class

any help is appreciated.



Is This A Good Question/Topic? 0
  • +

Replies To: mysql connection problem

#2 andrewsw   User is offline

  • never lube your breaks
  • member icon

Reputation: 6823
  • View blog
  • Posts: 28,272
  • Joined: 12-December 12

Re: mysql connection problem

Posted 28 October 2019 - 05:57 AM

Which line produces the error? And please provide fuller error details.

(Also worth mentioning is that "Object reference not set ..." doesn't necessarily indicate a problem with the connection, it sounds more likely to be some coding issue.)
Was This Post Helpful? 0
  • +
  • -

#3 GHviru5   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 28-October 19

Re: mysql connection problem

Posted 29 October 2019 - 09:15 AM

thanks, i found that my problem was that i did not allow MySQL remote access.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1