2012-03-07 12 views
1

WebMatrixを使用して自分のサイト(C#/ MVC3)を作成し、ローカルのmysqlサーバー(Webmatrix経由でインストールされていない)を使用してすべてのデータを保存しています。そこに私のサーバーはNew Connectionとして。しかし、私はHostのために何を置いてもエラーになります。私はdb名、ユーザ名&パスワードが正しいことを知っています。WebMatrix + MySQLリンク

web.configファイル:

<?xml version="1.0" encoding="UTF-8"?> 
<configuration> 
    <connectionStrings> 
     <add connectionString="Uid=username;Server=localhost;Database=mydb;Pwd=pass" name="localhost" providerName="System.Data.SqlClient" /> 
    </connectionStrings> 
</configuration> 

はコード:

@{ 
    Page.Title = "Comics"; 

    var db = Database.Open("localhost"); 
    var comics = db.Query(@"SELECT * FROM comics ORDER BY arc ASC").ToList(); 
} 

<h1>@Page.Title</h1> 

<ul class="thumbnails gallery"> 
    @foreach (var comic in comics) { 
     <li>@comic.Arc</li> 
    } 
</ul> 

エラー

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) 

は、すべてのヘルプは大歓迎です!

EDIT:

私は、MySQLコネクタをインストールし、私はまだエラーを取得しています:

Unable to find the requested .Net Framework Data Provider. It may not be installed. 

私はからそれをダウンロード:http://dev.mysql.com/downloads/mirror.php?id=403991と単にデフォルトの設定でそれをインストール。私はwebmatrixディレクトリにそれをインストールするはずですか?

新しいweb.configファイル:あなたは、接続のように(またはSQL Server(あなたのポストのタイトルと、選択したタグのように)あなたがMySQLを使用しているかどうかあなたの心を補うために必要

<?xml version="1.0" encoding="UTF-8"?> 
<configuration> 
    <connectionStrings> 
     <add connectionString="Server=localhost;Database=mydb;Uid=user;Pwd=pass;" name="localhost" providerName="MySql.Data.MySqlClient.MySqlConnection" /> 
    </connectionStrings> 
</configuration> 

答えて

2

文字列)。 MySQLを使用している場合は、別の接続文字列が必要です。

http://www.connectionstrings.com/mysql

+0

私はどちらを使いますか?私はそのページの最初のものを試して、それは仕事をしなかった。 – rackemup420

+0

nevermindが終わった私は、コネクタがインストールされていない...笑あなたはありがとう! – rackemup420

+0

まあ、私はコネクタをインストールし、それでもコネクタがないと言います。ここから入手してください:http://dev.mysql.com/downloads/mirror.php?id=403991 webmatrixディレクトリにインストールする必要がありますか? – rackemup420