2013-04-15 42 views
0

我在與我的編譯代碼,我是從編譯器收到以下錯誤麻煩:使用的自定義方法結果兩個實例「呼叫不明確」

的調用是模棱兩可之間以下方法或屬性:「ActionTracker.DataAccess.GetSpecialtyCode(字符串)」和ActionTracker.DataAccess.GetSpecialtyCode

我只是再次使用的新方法,我的自定義方法。我用完全相同的方式使用了另一種方法,並且我沒有得到任何模糊性錯誤。請有人可以幫忙嗎?我是一個的n00b:d

namespace ActionTracker 
{ 
    using ... 
    internal class DataAccess 
    { 
    internal static string GetSpecialtyCode(string name) 
    { 
     OleDbConnection speccconn = SetUpConnection(); 
     speccconn.Open(); 
     OleDbCommand specccmd = new OleDbCommand("SELECT Specialty_Code FROM tbl_specialty WHERE Specialty_Description = @Specialty_Description", speccconn); 

     specccmd.Parameters.Add("@Specialty_Description", OleDbType.VarWChar, 255).Value = name; 

     string code = (string)specccmd.ExecuteScalar(); 
     speccconn.Close(); 
     return code; 
    } 

    internal static string AddVisitSpecialty(string trust_name, DateTime visit_date, string visit_type, List<string> specialties) 
    { 
      int visit_id = GetVisitID(trust_name, visit_date, visit_type); 
      OleDbConnection visitspeccon = SetUpConnection(); 
      visitspeccon.Open(); 

      foreach (string element in specialties) 
      { 
      string specialty_code = new GetSpecialtyCode(element); 
      OleDbCommand visitspeccmmd = new OleDbCommand("INSERT INTO tbl_visit_specialty (Visit_ID, Visit_Specialty) VALUES" 
      + "(@visit_id, @visit_specialty)", visitspeccon); 
      visitspeccmmd.Parameters.Add("@visit_id", OleDbType.Numeric).Value = visit_id; 
      visitspeccmmd.Parameters.Add("@visit_specialty", OleDbType.VarWChar, 255).Value = specialty_code; 
      visitspeccmmd.ExecuteNonQuery(); 

      } 

      visitspeccon.Close(); 

      string message = "Specialty(s) added to visit"; 
      return message; 
    } 

    internal static string DeleteVisitSpecialty(int visit_id, List<string> specialty_list) 
    { 
     OleDbConnection delvscon = SetUpConnection(); 
     delvscon.Open();  
     List<string> specialty_codes = new List<string>(); 

     foreach (string element in specialty_list) 
     { 
      string specialty_code = GetSpecialtyCode(element);    
      OleDbCommand delvscmd = new OleDbCommand("DELETE FROM tbl_visit_specilaty WHERE Visit_ID = @visit_id AND Visit_Specialty = @visit_specialty", delvscon); 
      delvscmd.Parameters.Add("@visit_id", OleDbType.Numeric).Value = visit_id; 
      delvscmd.Parameters.Add("@visit_specialty", OleDbType.VarWChar, 255).Value = specialty_code; 
      delvscmd.ExecuteNonQuery(); 
     } 

     delvscon.Close(); 
     string message = "Specialty(s) deleted"; 
     return message; 
     } 
    } 
} 
+0

你有* *屬性*稱爲'GetSpecialtyCode'或類似的東西? –

+0

你已經在兩個不同的地方定義了'GetSpecialtyCode'。 –

+0

而另一個定義不在您複製的代碼塊中。 – Bobson

回答

0

我覺得你的問題是這條線(從AddVisitSpecialty):

string specialty_code = new GetSpecialtyCode(element); 

看看你是否刪除會發生什麼。