My error is:
System.Data.OleDb.OleDbException: 'Invalid SQL statement; expected 'DELETE', 'INSERT', 'PROCEDURE', 'SELECT', or 'UPDATE'.'
Here is my code, and i checked to make sure all those fields exist in my access datatbase and they do. some are out of order but that shouldnt be an issue right?
command.CommandText = "if not exists ( select PatientID from patienttable where PatientID = " + PatientID.Text + " ) begin INSERT INTO patienttable VALUES (" + Convert.ToInt32(PatientID.Text) + "','" + OldID.Text + "','"
+ PtLastName.Text
+ "','" + PtPreviousLastName.Text + "','" + PtFirstName.Text +
"','" + HomeAddress1.Text + "','"
+ HomeAddress2.Text + "','" + HomeCity.Text
+ "','" + HomeStateProvinceRegion.Text + "','"
+ HomeZip.Text + "','" + Country.Text + "','"
+ Citizenship.Text + PtHomePhone.Text + "','"
+ EmergencyPhoneNumber.Text + "','" +
PtHomeFax.Text+ "','" +Pager.Text+ "','" + EmailAddress.Text
+ "','" + PtSS.Text + "','"
+ DOB.Text + "','" + Gender.Text + "','"
+ EthnicAssociation.Text + "','" + Religion.Text + EthnicAssociation.Text + "','" + MaritalStatus.Text + "','"
+ "','" + EmploymentStatus.Text + "','" + HospitalMR.Text + "','" + DateofExpire.Text + "','" + Referral.Text + "','" + CurrentPrimaryHCPId.Text + "','" + Specialist1.Text + "','" + Specialist2.Text + "','" + Specialist3.Text + "','" + Specialist4.Text + "','" + OriginalStaffHCP.Text + "','" + CurrentStaffHCP.Text + "','" + Active.Checked + "','"
+ Comments.Text + "','" + DateEntered.Text
+ "','" + BusinessPhone.Text + "','" + BusinessFax.Text + "','" + SubscriberRelationship.Text + "','" + EmployerID.Text + "','" + NextOfKinID.Text + "','" + PtMiddleInitial.Text + "','" + NextOfKinRelationshipToPatient.Text + "','" + NoticeOfPracticePrivacy.Checked + "','" + NPPDate.Text + "','" + Suffix.Text + "') end else begin update patienttable set" +
"PatientID=" + PatientID.Text +
",OldID="+ "'"+ OldID.Text +"'"+
",PtLastName='" + PtLastName.Text + "'" +
",PtPreviousLastName='" + PtPreviousLastName.Text + "'" +
",PtFirstName='" + PtFirstName.Text +"'" +
",HomeAddress1='" + HomeAddress1.Text + "'" +
",HomeAddress2='" + HomeAddress2.Text + "'" +
",HomeCity='" + HomeCity.Text + "'" +
",HomeStateProvinceRegion='" + HomeStateProvinceRegion.Text +"'" +
",HomeZip='" + HomeZip.Text +"'" +
",Country='" + Country.Text +"'" +
",Citizenship='" + Citizenship.Text +"'" +
",PtHomePhone='" + PtHomePhone.Text +"'" +
",EmergencyPhoneNumber='" + EmergencyPhoneNumber.Text + "'" +
",PtHomeFax='" + PtHomeFax.Text + "'" +
",Pager='" + Pager.Text + "'" +
",EmailAddress='" + EmailAddress.Text + "'" +
",PtSS='" + PtSS.Text + "'" +
",DOB='" + DOB.Text + "'" +
",Gender='" + Gender.Text + "'" +
",EthnicAssociation='" + EthnicAssociation.Text + "'" +
",Religion='" + Religion.Text + "'" +
",MaritalStatus='" + MaritalStatus.Text + "'" +
",EmploymentStatus='" + EmploymentStatus.Text + "'" +
",HospitalMR='" + HospitalMR.Text + "'" +
",DateofExpire='" + DateofExpire.Text + "'" +
",Referral='" + Referral.Text + "'" +
",CurrentPrimaryHCPId ='" + CurrentPrimaryHCPId.Text + "'" +
",Specialist1='" + Specialist1.Text +"'" +
",Specialist2='" + Specialist2.Text +"'" +
",Specialist3='" + Specialist3.Text +"'" +
",Specialist4='" + Specialist4.Text +"'" +
",OriginalStaffHCP='" + OriginalStaffHCP.Text + "'" +
",CurrentStaffHCP= '" + CurrentStaffHCP.Text + "'" +
",Active='" + Active.Text + "'" +
",Comments='" + Comments.Text + "'" +
",DateEntered='" + DateEntered.Text +"'" +
",BusinessPhone='" + BusinessPhone.Text + "'" +
",BusinessFax='" + BusinessFax.Text +"'" +
",SubscriberRelationship='" + SubscriberRelationship.Text + "'" +
",EmployerID='" + EmployerID.Text + "'" +
",NextOfKinID='" + NextOfKinID.Text +"'" +
",PtMiddleInitial='" + PtMiddleInitial.Text + "'" +
",NextOfKinRelationshipToPatient ='" + NextOfKinRelationshipToPatient.Text + "'" +
",NoticeOfPracticePrivacy='" + NoticeOfPracticePrivacy.Text + "'" +
",NPPDate='" + NPPDate.ToString() + "'" +
",Suffix='" + Suffix.Text + "'" +
" where PatientID = " + PatientID.Text+
" end ";