2012-03-07 2 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) 

어떤 도움이 크게 감사합니다!

는 편집 :

나는 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

어느 것을 사용해야합니까? 나는 그 페이지에 첫번째 것을 시도하고 그것은 일을 didnt한다. – rackemup420

+0

nevermind는 내가 커넥터를 설치하지 못하게했다. – rackemup420

+0

글쎄 커넥터를 설치했지만 여전히 커넥터가 누락되었다고 말합니다. 여기에서 알 수 있습니다 : http://dev.mysql.com/downloads/mirror.php?id=403991. webmatrix 디렉토리에 설치해야합니까? – rackemup420