2013-12-21 4 views
-1

메신저 localhos 에 MySQL 데이터베이스에 저장 솜 데이터하려고하지만 난이 메시지 가지고 로컬 호스트 : 사용자에 대한 로그인 필드 '루트를로그인 필드 ... MySQL의

메신저 uid가 확실하고 pws가 맞습니다.

private void button1_Click_1(object sender, EventArgs e) 
    { 
     String connection = "server=localhost; user =root; Pwd=password;database=skradderi;"; 
     SqlConnection conn = new SqlConnection(connection); 
     SqlCommand cmd = new SqlCommand("INSERT INTO kunder(Namn ,Adress ,telfon ,OrgNr)VALUES ('" + txtboxName.Text + "','" + txtboxAdress.Text + "','" + txtboxPostNr.Text + "','" + txtOrgNr.Text + "')"); 
     try 
     { 
      conn.Open(); 
     } 
     catch (SqlException ex) 
     { 
      MessageBox.Show(ex.Message); 
     } 
+0

"server = (local); ..."대신 "server = localhost; ..."를 사용해 보셨습니까? Ref : http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlconnection.connectionstring(v=vs.110).aspx –

+0

연결 필드 – user2269364

답변

0

나는 그것이 작동하지 않는 이유를 알아 냈습니다. 연결 문자열은 MySQL 용이지만 SQL 연결은 사용하고 있습니다. 올바른 연결 문자열은 다음과 같습니다.

"데이터 원본 = ENTERPRISE-PC; 초기 카탈로그 = 통합 보안 = True";