Click here to Skip to main content
15,885,182 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have an xampp installed in PC1. My project is in PC2. I changed my connection string's server from localhost into this:

HTML
<add name="VoteContext" providerName="MySql.Data.MySqlClient"
connectionString="server=192.168.0.124; database=voting; user id=root;password=;/>

But when I run with debug my project, it says:
C#
PC2 is not allowed to connect to this MariaDB server


I also have an xampp installed in PC2 with the same db. When I use this connection string,

HTML
<add name="VoteContext" providerName="MySql.Data.MySqlClient"
connectionString="server=localhost; database=voting; user id=root;password=;"/>

it goes fine.

But when I change the "localhost" into PC2's ipaddress,

HTML
<add name="VoteContext" providerName="MySql.Data.MySqlClient"
connectionString="server=192.168.0.123; database=voting; user id=root;password=;"/>

the same error message appears.

I'd like to connect my PC2 project to PC1 db.

I already configured my xampp settings httpd-xampp.conf and I can access the xampp of PC1 using my browser in PC2 (192.168.0.124/phpmyadmin) and I successfully inserted a record but still, I couldnt connect to PC1 server with my visual studio project.

What I have tried:

<add name="VoteContext" providerName="MySql.Data.MySqlClient"
connectionString="server=192.168.0.124; database=voting; user id=root;password=;/>
Posted
Updated 27-Oct-18 22:51pm

1 solution

Check the configuration on the remote machine: it could be the MySql installation requires different credential (and I would seriously hope so, blank passwords on a DB are not a good idea particularly on an "admin" account) or it could be the firewall.

See if you can find a working example connections string to s different DB on the same server and copy that.

BTW: Generally, you'd be better off specifying a Hostname rather than an IP address as the latter are normally issued on a "first come, first served" basis when the router is powered up. Which means that you can't guarantee that "x.x.0.124" will be the same host tomorrow!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900