這是不允許的?Linq to SQL最好的重載方法匹配錯誤
public void addInsertedInformationToDb() {
using(DbClassesDataContext myDb = new DbClassesDataContext(dbPath)){
myDb.PatientInfos.InsertOnSubmit(insertPersonalInformation);
}
}
凡我insertPersonalInformation
private PatientInfo insertPersonalInformation()
{
DbClassesDataContext myDb = new DbClassesDataContext(dbPath);
PatientInfo patientInfo = new PatientInfo();
patientInfo.Phy_ID = physcianID;
patientInfo.Pat_First_Name = txtFirstName.Text;
patientInfo.Pat_Middle_Name = txtMiddleName.Text;
patientInfo.Pat_Last_Name = txtLastName.Text;
patientInfo.Pat_Gender = cmbGender.Text;
patientInfo.Pat_Marital_Status = cmbMaritalStatus.Text;
patientInfo.Pat_Date_Of_Birth = dtpDOB.Value;
patientInfo.Pat_Home_Add = txtHomeAdd.Text;
patientInfo.Pat_Home_Num = txtPhone.Text;
patientInfo.Pat_Work_Add = txtWorkAdd.Text;
patientInfo.Pat_Work_Num = txtWorkPhone.Text;
patientInfo.Pat_Prim_Physician = txtPrimPhysician.Text;
patientInfo.Pat_Ref_Physician = txtRefePhysician.Text;
return patientInfo;
}
我不停地收到這些錯誤
錯誤1「System.Data.Linq.Table.InsertOnSubmit(PatientAdministration最佳重載的方法匹配。 PatientInfo)'有一些無效參數C:\ Users \ John \ documents \ visual studio 2010 \ Projects \ PatientAdministration \ PatientAdministration \ Pat_Demog.cs 101 17患者管理
錯誤2參數1:不能從 '方法組' 到 'PatientAdministration.PatientInfo' C轉換:\用戶\約翰\文件\視覺工作室2010 \項目\ PatientAdministration \ PatientAdministration \ Pat_Demog.cs 101 50 PatientAdministration
這是什麼修復?
如何添加數據? – user962206 2012-03-04 11:57:06
@ user962206與插入相同。請參閱更新引用鏈接的部分,您應該更新更新(事實上,您應該先取實體,然後應用更改)。 – 2012-03-04 11:58:32
但我正在使用表單。您所顯示的鏈接僅顯示某個部分如果我想選擇多個部分? – user962206 2012-03-04 12:03:22