kwh3856
asked on
A Relation named 'Patient' already belongs to this DataSet. How do you get a duplicate relation when only one relation is configured?
I am trying to setup a relation between two tables but keep getting this error message trapped.
A Relation named 'Patient' already belongs to this DataSet.
Can someone point me in the right direction?
Here is my code:
-------------------------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ------
protected void btnPreAuthSearch_Click(obj ect sender, Infragistics.WebUI.WebData Input.Butt onEventArg s e)
{
bool authenticated;
authenticated = Convert.ToBoolean(Session[ "authentic ated"]);
if (authenticated)
{
PopulatePatientDS();
this.PreAuthWebGrid1.DataS ource = HDSDataSet.Tables["Patient "];
this.PreAuthWebGrid1.Displ ayLayout.A utoGenerat eColumns = false;
PreAuthWebGrid1.DisplayLay out.Bands. Clear();
this.PreAuthWebGrid1.DataB ind();
}
}
//------------ Patient Search Tab
public DataSet HDSDataSet
{
get
{
if (Cache["HDSDataSet"] == null)
Cache["HDSDataSet"] = new DataSet("HDSDataSet");
return (DataSet)Cache["HDSDataSet "];
}
}
//------------ Patient Search Tab
protected void PopulatePatientDS()
{
SqlDataAdapter sqlDA = CreatePatientAdapter();
SqlDataAdapter sqlDAPreAuth = CreatePreAuthAdapter();
HDSDataSet.Clear();
sqlDA.FillSchema(HDSDataSe t, SchemaType.Source);
sqlDA.Fill(HDSDataSet, "Patient");
sqlDAPreAuth.Fill(HDSDataS et, "Pre_Auth");
try
{
HDSDataSet.Relations.Add(" Patient",- ---------- ---------- ---------- ---------- ---------- DATA RELATION SET HERE -------------------------- -------
HDSDataSet.Tables["Patient "].Columns ["MPI"],
HDSDataSet.Tables["Pre_Aut h"].Column s["MPI"]);
}
catch (System.Exception x)
{
string s = x.Message;---------------- ---------- ---------- ---------- ---------- ---------- -----ERROR is TRAPPED HERE -------------------------- --
string m = s;
}
}
//------------ Patient Adapter
protected SqlDataAdapter CreatePatientAdapter()
{
string physicianNPI;
physicianNPI = Session["physicianNPI"].To String();
SqlConnection conn = new SqlConnection(ConnString);
SqlCommand cmd = new SqlCommand(SearchString, conn);
cmd.Parameters.Add("@REFER RING_PROVI DER_NPI", SqlDbType.VarChar).Value = physicianNPI;
cmd.Parameters.Add(new SqlParameter("@SearchFn", tbPreAuthFname.Text));
cmd.Parameters.Add(new SqlParameter("@SearchLn", tbPreAuthLname.Text));
cmd.Parameters.Add(new SqlParameter("@SearchAddre ss", tbPreAuthAddress.Text));
cmd.Parameters.Add(new SqlParameter("@SearchDOB", tbPreAuthDOB.Text));
cmd.Parameters.Add(new SqlParameter("@SearchSSN", tbPreAuthSSN.Text));
cmd.Parameters.Add(new SqlParameter("@SearchDL", tbPreAuthDL.Text));
cmd.Parameters.Add(new SqlParameter("@SearchPhn", tbPreAuthPhone.Text));
cmd.Parameters.Add(new SqlParameter("@SearchBilli ngId", tbPreAuthAccountNum.Text)) ;
cmd.Parameters.Add(new SqlParameter("@SearchSex", tbPreAuthSex.Text));
SqlDataAdapter sqlDA = new SqlDataAdapter(cmd);
return sqlDA;
}
//------------ Patient Search Tab
private String ConnString
{
get
{
//HDS ConnectionString comes from the Web.Config
return ConfigurationManager.Conne ctionStrin gs["123121 Connection String"].C onnectionS tring;
}
}
//------------ Patient Search Tab
private String SearchString
{
get
{
String srchCmd = "SELECT PATIENT.MPI, PATIENT.LAST_NAME, PATIENT.FIRST_NAME, PRIMARY_INSURANCE.PLAN_NAM E, PATIENT.DATE_OF_BIRTH, PATIENT.SEX FROM PATIENT LEFT JOIN PRIMARY_INSURANCE ON PATIENT.MPI = PRIMARY_INSURANCE.MPI WHERE PATIENT.LAST_NAME = @SearchLn OR PATIENT.FIRST_NAME = @SearchFn";
return srchCmd;
}
}
//------------ PreAuthAdapter
protected SqlDataAdapter CreatePreAuthAdapter()
{
SqlConnection conn = new SqlConnection(ConnString);
SqlCommand cmd = new SqlCommand(PreAuthSearchSt ring, conn);
SqlDataAdapter sqlDAPreAuth = new SqlDataAdapter(cmd);
return sqlDAPreAuth;
}
//------------ PreAuth Search Command
private String PreAuthSearchString
{
get
{
String srchCmd = "SELECT PRE_AUTH.MPI, PRE_AUTH.INSURANCE_NAME, PRE_AUTH.PRE_AUTH_NUM, PRE_AUTH.EXPIRY_DATE, PRE_AUTH.VISITS FROM PRE_AUTH";
return srchCmd;
}
}
A Relation named 'Patient' already belongs to this DataSet.
Can someone point me in the right direction?
Here is my code:
--------------------------
protected void btnPreAuthSearch_Click(obj
{
bool authenticated;
authenticated = Convert.ToBoolean(Session[
if (authenticated)
{
PopulatePatientDS();
this.PreAuthWebGrid1.DataS
this.PreAuthWebGrid1.Displ
PreAuthWebGrid1.DisplayLay
this.PreAuthWebGrid1.DataB
}
}
//------------ Patient Search Tab
public DataSet HDSDataSet
{
get
{
if (Cache["HDSDataSet"] == null)
Cache["HDSDataSet"] = new DataSet("HDSDataSet");
return (DataSet)Cache["HDSDataSet
}
}
//------------ Patient Search Tab
protected void PopulatePatientDS()
{
SqlDataAdapter sqlDA = CreatePatientAdapter();
SqlDataAdapter sqlDAPreAuth = CreatePreAuthAdapter();
HDSDataSet.Clear();
sqlDA.FillSchema(HDSDataSe
sqlDA.Fill(HDSDataSet, "Patient");
sqlDAPreAuth.Fill(HDSDataS
try
{
HDSDataSet.Relations.Add("
HDSDataSet.Tables["Patient
HDSDataSet.Tables["Pre_Aut
}
catch (System.Exception x)
{
string s = x.Message;----------------
string m = s;
}
}
//------------ Patient Adapter
protected SqlDataAdapter CreatePatientAdapter()
{
string physicianNPI;
physicianNPI = Session["physicianNPI"].To
SqlConnection conn = new SqlConnection(ConnString);
SqlCommand cmd = new SqlCommand(SearchString, conn);
cmd.Parameters.Add("@REFER
cmd.Parameters.Add(new SqlParameter("@SearchFn", tbPreAuthFname.Text));
cmd.Parameters.Add(new SqlParameter("@SearchLn", tbPreAuthLname.Text));
cmd.Parameters.Add(new SqlParameter("@SearchAddre
cmd.Parameters.Add(new SqlParameter("@SearchDOB",
cmd.Parameters.Add(new SqlParameter("@SearchSSN",
cmd.Parameters.Add(new SqlParameter("@SearchDL", tbPreAuthDL.Text));
cmd.Parameters.Add(new SqlParameter("@SearchPhn",
cmd.Parameters.Add(new SqlParameter("@SearchBilli
cmd.Parameters.Add(new SqlParameter("@SearchSex",
SqlDataAdapter sqlDA = new SqlDataAdapter(cmd);
return sqlDA;
}
//------------ Patient Search Tab
private String ConnString
{
get
{
//HDS ConnectionString comes from the Web.Config
return ConfigurationManager.Conne
}
}
//------------ Patient Search Tab
private String SearchString
{
get
{
String srchCmd = "SELECT PATIENT.MPI, PATIENT.LAST_NAME, PATIENT.FIRST_NAME, PRIMARY_INSURANCE.PLAN_NAM
return srchCmd;
}
}
//------------ PreAuthAdapter
protected SqlDataAdapter CreatePreAuthAdapter()
{
SqlConnection conn = new SqlConnection(ConnString);
SqlCommand cmd = new SqlCommand(PreAuthSearchSt
SqlDataAdapter sqlDAPreAuth = new SqlDataAdapter(cmd);
return sqlDAPreAuth;
}
//------------ PreAuth Search Command
private String PreAuthSearchString
{
get
{
String srchCmd = "SELECT PRE_AUTH.MPI, PRE_AUTH.INSURANCE_NAME, PRE_AUTH.PRE_AUTH_NUM, PRE_AUTH.EXPIRY_DATE, PRE_AUTH.VISITS FROM PRE_AUTH";
return srchCmd;
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Resolved Problem with the remove command. I think the actual problem was due to caching.
protected void PopulatePatientDS()
{
SqlDataAdapter sqlDA = CreatePatientAdapter();
SqlDataAdapter sqlDAPreAuth = CreatePreAuthAdapter();
HDSDataSet.Clear();
sqlDA.FillSchema(HDSDataSe t, SchemaType.Source);
sqlDA.Fill(HDSDataSet, "Patient");
sqlDAPreAuth.Fill(HDSDataS et, "Pre_Auth");
try
{
HDSDataSet.Relations.Remov e("Patient Relation") ; -------------------------- ---------- ---------- --Fixed problem------------------- ---------- --
HDSDataSet.Relations.Add(" PatientRel ation",
HDSDataSet.Tables["Patient "].Columns ["MPI"],
HDSDataSet.Tables["Pre_Aut h"].Column s["MPI"]);
}
catch (System.Exception x)
{
string s = x.Message;
string m = s;
}
this.PreAuthWebGrid1.DataS ource = HDSDataSet.Tables["Patient "];
this.PreAuthWebGrid1.Displ ayLayout.A utoGenerat eColumns = false;
PreAuthWebGrid1.DisplayLay out.Bands. Clear();
this.PreAuthWebGrid1.DataB ind();
protected void PopulatePatientDS()
{
SqlDataAdapter sqlDA = CreatePatientAdapter();
SqlDataAdapter sqlDAPreAuth = CreatePreAuthAdapter();
HDSDataSet.Clear();
sqlDA.FillSchema(HDSDataSe
sqlDA.Fill(HDSDataSet, "Patient");
sqlDAPreAuth.Fill(HDSDataS
try
{
HDSDataSet.Relations.Remov
HDSDataSet.Relations.Add("
HDSDataSet.Tables["Patient
HDSDataSet.Tables["Pre_Aut
}
catch (System.Exception x)
{
string s = x.Message;
string m = s;
}
this.PreAuthWebGrid1.DataS
this.PreAuthWebGrid1.Displ
PreAuthWebGrid1.DisplayLay
this.PreAuthWebGrid1.DataB
ASKER
jgordos,
I resolved the problem whith the remove command. I wanted to award you the points for trying to help me. Thanks for your assistance.
I resolved the problem whith the remove command. I wanted to award you the points for trying to help me. Thanks for your assistance.
ASKER
If I do not do the .fill on the table then when I look at my dataset there are no records on the table. Is there some other way to accomplish this task?
Thanks
Kenny