Connecting to a MySQL DB from a WPF app -
i have been trying connect c# wpf app mysql database. database on linux machine in network. have lot of experience connecting php have never done .net product. have read through have found online. have downloaded , installed mysql connect stuff , attached project. have gone db , made sure accept queries work pc using phpmyadmin. have tried wide variety of code call db. have changed order of in connstr. have changed labels , formatting try have come across. able connect db of web based tools tie app know have right info. have never posted on here sorry formatting. have read make sound quite straightforward. , using this:
string connstr = "user=admin;database=test;server=192.168.0.37;password=******;"; mysqlconnection conn = new mysqlconnection(connstr); try { console.writeline("trying connect to: ..." + connstr); console.writeline("connecting mysql..."); conn.open(); // perform database operations } catch (exception ex) { console.writeline(ex.tostring()); } conn.close(); console.writeline("done.");
and getting error:
test.vshost.exe error: 0 : unable connect of specified mysql hosts. first chance exception of type 'mysql.data.mysqlclient.mysqlexception' occurred in mysql.data.dll mysql.data.mysqlclient.mysqlexception (0x80004005): unable connect of specified mysql hosts. @ mysql.data.mysqlclient.nativedriver.open()...
thank on this!
when trying contact server in home network using basic modem/router, can fail recognize or pass along port number sent. in case not recognizing or sending 3306 (default mysql). make never work without ssh tunneling. after adding ssh tunneling worked advertised.
Comments
Post a Comment