0

here 지침에 따라 LightSwitch 2012 응용 프로그램 내에서 (매개 변수없는) MySQL SP를 호출합니다. 이 인용 된 지침은 SQL Server SP에 대한 것입니다. 여기 Lightswitch에서 MySQL 저장 프로 시저를 호출하는 방법?

은 관련 코드입니다 : ". 사용자가 로그인 '루트'실패"이것은 SQLException이 함께 connection.Open();에 실패

using System; 
using System.Configuration; 
using System.Data; 
using System.Data.SqlClient; 
using System.Linq; 

namespace LightSwitchApplication 
{ 
    public partial class StoredProcceduresService 
    { 
     partial void MakeMasterOperations_Inserting(MakeMasterOperation entity) 
     { 
      using (SqlConnection connection = new SqlConnection()) 
      { 
       string connectionStringName = this.DataWorkspace.SystemInfo.Details.Name; 
       connection.ConnectionString = ConfigurationManager.ConnectionStrings[connectionStringName].ConnectionString; 

       string storedProcedure = "make_master"; 
       using (SqlCommand command = new SqlCommand(storedProcedure, connection)) 
       { 
        command.CommandType = CommandType.StoredProcedure; 
        connection.Open(); 
        command.ExecuteNonQuery(); 
       }    
      } 
     this.Details.DiscardChanges(); 
     } 
    } 
} 

LightSwitch 내에서 동일한 연결 문자열을 사용하는 다른 데이터베이스 조작이 정상적으로 작동하므로 사용자 ID와 비밀번호가 괜찮음을 알고 있습니다.

LightSwitch에서 MySQL SP를 호출 할 수 있습니까? 그렇다면 어떻게?

답변

0

글쎄, 나는 그 해답을 발견했다. 대신 SQL 서버의 MySQL을 사용하기 위해

, 하나에 코드를 서버 프로젝트에 MySql.Data에 대한 참조를 추가하고 변경할 수 있습니다

using System; 
    using System.Configuration; 
    using System.Data; 
    using System.Linq; 
    using MySql.Data.MySqlClient; 

    namespace LightSwitchApplication 
    { 
     public partial class StoredProcceduresService 
     { 
      partial void MakeMasterOperations_Inserting(MakeMasterOperation entity) 
      { 
       using (MySqlConnection connection = new MySqlConnection()) 
       { 
        string connectionStringName = this.DataWorkspace.SystemInfo.Details.Name; 
        connection.ConnectionString = ConfigurationManager.ConnectionStrings[connectionStringName].ConnectionString; 

        string storedProcedure = "make_master"; 
        using (MySqlCommand command = new MySqlCommand(storedProcedure, connection)) 
        { 
         command.CommandType = CommandType.StoredProcedure; 
         connection.Open(); 
         command.ExecuteNonQuery(); 
        }    
       } 
      this.Details.DiscardChanges(); 
      } 
     } 
    } 

이있는 것은 아니다 너무 나쁜 사용되는 DB 서버에 따라 인스턴스화 할 수있는 공통 기본 클래스.

관련 문제