2011-12-14 3 views
4

실패 "제출"버튼을 클릭하면 :도록 SqlConnection의 로컬 호스트는이 ASP.Net에서 데이터베이스를 사용하려고 내 처음이며, 여기에 문제가있는 사용자 이름

사용자 코드가 SQLException을 처리하지 못했습니다. 로그인은 "사용자 실패했습니다.

protected void Register_Click(object sender, EventArgs e) 
    { 
     SqlConnection connection = new SqlConnection("server = localhost ;uid=; Password= database = Movies;"); 
     connection.Open(); 
     //FirstName*********** 
     string firstName = UsernameTextBox.Text; 
     string sqlquery = ("INSERT INTO [Movie] (FirstName) VALUES (' " +FirstNameTextBox.Text + " ' "); 

     SqlCommand command = new SqlCommand(sqlquery , connection); 
     command.Parameters.AddWithValue("FirstName", firstName); 

서버가 내 컴퓨터에 있기 때문에

, 나는 어떤 이름을 가지고 있겠지 바로!

답변

3

당신은 사용자 이름과 암호가 필요하지, 그렇지 않으면 당신이 사용할 필요가 . 다음과 같이 Windows 자격 증명이 사용되는 것을 의미 통합 보안,

당신은 연결에 통합 보안을 추가 할 수 있습니다

SqlConnection connection = new SqlConnection("server = localhost ;integrated security=SSPI; database = Movies;"); 

연결 문자열에 대한 유용한 리소스는 http://www.connectionstrings.com

+0

감사 포맷하기에 문제가있는 경우 빠른 응답 : – thormayer

+0

그것은 작동하지 않지만. 그것은 말합니다 : "키워드가지지되지 않음"이며 밑줄없이 integrated_security – thormayer

+1

@ user1054375는 "통합 보안"을 사용합니다. – vcsjones

1

입니다. SQL 서버는 컴퓨터 또는 원격 시스템에 관계없이 항상 사용자 이름이 필요합니다.

나는 www.asp.net를 찾고 제안 또는 SQL Server의 patricular 버전을 구성하는 방법을 찾기 위해 구글을 시도 할 것

1

확인 connectionstrings이 site 당신은 ConnectionString을에게