2016-04-26 21 views
0

私は最近、OpenShiftに入っています。自分のドメインにMySQL DBをセットアップし、phpMyAdminページからアイテムを追加したり削除したりできます。私は今、自分のマシン上でアプリケーションを作成し、DBに接続するための私のマシン上でのみ、読み取り/書き込みアクセス権を持つことができます。私はすでにこのユーザーのためのアクセス許可セットを作成し、C#フォームをコーディングの準備ができました。OpenShiftサービスに接続

W:\>rhc port-forward --app <my application name> 
DL is deprecated, please use Fiddle 
Checking available ports ... done 
Forwarding ports ... 
Only one usage of each socket address (protocol/network address/port) is 
normally permitted. - bind(2) while forwarding port 8080. Trying local port 8081 
To connect to a service running on OpenShift, use the Local address 
Service Local    OpenShift 
httpd 127.0.0.1:8080 => 127.3.223.1:8080 
httpd 127.0.0.1:8081 => 127.3.223.3:8080 
mysql 127.0.0.1:3306 => 127.3.223.2:3306 
Press CTRL-C to terminate port forwarding 

そして、私はC#のに戻ったときにそう、私は次のコード行があります:

conn = new SqlConnection("user id="+tbUser.Text+";password="+tbPass.Text+";server=127.0.0.1:3306;database=<my application name>"); 
conn.Open(); 

rhc port-forward --app <my application name> 

とし、その後、私は次のように受け取っ:私はすでに次のように行われています

しかし、サーバーやデータベースが見つからないという.Open()関数でエラーが発生します。私は何が起こっているのか分からない。

編集:私は全く有益な場合、私は、同様のエラーメッセージを追加するかもしれないと思った:

An unhandled exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dll 
Additional information: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) 

答えて

2

あなたは、IPアドレスの代わりにアプリケーションのURLを使用する必要があり、あなたが記載されているすべてのアドレスはloopback interfaceで、ではありませんあなたのアプリケーションのURLを代表する

お試しください。http://yourappdomain.rhcloud.com:3306

関連する問題