Solved

Parent Columns and Child Columns don't have type-matching columns

Posted on 2008-10-23
3
2,855 Views
Last Modified: 2012-05-05
I am trying to create a data relation but keep getting this error message.  Can someone point me in the right direction?

The field MPI in the patient table is set to numeric (35,0) not null primary key

The field MPI in the PreAuth table is set to numeric (35,0) nut null primary key


Here is my code:

---------------------------------------------------------------------------------



//------------   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(HDSDataSet, SchemaType.Source);
            sqlDA.Fill(HDSDataSet, "Patient");
        sqlDAPreAuth.Fill(HDSDataSet, "Pre_Auth");

        try
        {
            HDSDataSet.Relations.Add("Patient",
                HDSDataSet.Tables["Patient"].Columns["MPI"],
                HDSDataSet.Tables["Pre_Auth"].Columns["MPI"]);
        }
        catch (System.Exception x)
        {
            string s = x.Message;-------------------------------------------------I trap the ERROR MESSAGE HERE   ------------------------------------
            string m = s;
        }

       
    }



      //------------   Patient Adapter
      protected SqlDataAdapter CreatePatientAdapter()
      {

        string physicianNPI;
        physicianNPI = Session["physicianNPI"].ToString();

            SqlConnection conn = new SqlConnection(ConnString);
            SqlCommand cmd = new SqlCommand(SearchString, conn);
        cmd.Parameters.Add("@REFERRING_PROVIDER_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("@SearchAddress", 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("@SearchBillingId", 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.ConnectionStrings["123123ConnectionString"].ConnectionString;

            }
      }

      //------------   Patient Search Tab
      private String SearchString
      {
            get
            {
            String srchCmd = "SELECT PATIENT.MPI, PATIENT.LAST_NAME, PATIENT.FIRST_NAME, PRIMARY_INSURANCE.PLAN_NAME, 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(PreAuthSearchString, conn);
        SqlDataAdapter sqlDAPreAuth = new SqlDataAdapter(cmd);
        return sqlDAPreAuth;
    }

   

    //------------   PreAuth Search Command
    private String PreAuthSearchString
    {
        get
        {
            String srchCmd = "SELECT * FROM PRE_AUTH";
            return srchCmd;

        }
    }





----------------------------------------------------------------------------------

Here is the PATIENT table structures


CREATE TABLE [dbo].[PATIENT](
      [MPI] [numeric](35, 0) NOT NULL,
      [NEWPATIENT] [bit] NULL,
      [SSN] [numeric](9, 0) NULL,
      [DRIVER_LICENSE] [numeric](15, 0) NULL,
      [LAST_NAME] [varchar](20) NULL,
      [FIRST_NAME] [varchar](20) NULL,
      [FIRST_NAME_SEC] [numeric](4, 0) NULL,
      [ADDRESS1] [varchar](20) NULL,
      [ADDRESS2] [varchar](20) NULL,
      [CITY] [varchar](20) NULL,
      [STATE] [varchar](3) NULL,
      [ZIP] [numeric](9, 0) NULL,
       CONSTRAINT [PK__PATIENT__7E6CC920] PRIMARY KEY CLUSTERED
(
      [MPI] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]



Here is Structure for PRE_AUTH

U
CREATE TABLE [dbo].[PRE_AUTH](
      [MPI] [numeric](35, 0) NOT NULL,
      [REFERRAL_QUEUE_ID] [numeric](15, 0) NULL,
      [INSURANCE_COMPANY_CODE] [varchar](35) NULL,
      [INSURANCE_NAME] [varchar](35) NULL,
 CONSTRAINT [PK_PRE_AUTH] PRIMARY KEY CLUSTERED
(
      [MPI] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

0
Comment
Question by:kwh3856
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 26

Accepted Solution

by:
Anurag Thakur earned 500 total points
ID: 22793216
does the following link give you any solutions for your problem
http://www.experts-exchange.com/Programming/Languages/C_Sharp/Q_20914806.html
0
 

Author Comment

by:kwh3856
ID: 22798282
Problem solved.

Evidently, I originally had a mismatch in the type for the columns.  I had resolved that problem but the system did not pickup the change that I made in the SQL table.  I am guessing that it was cached in my dataset.  After I rebooted my machine the error went away.
0
 

Author Closing Comment

by:kwh3856
ID: 31509469
Raqi,
That solution did not correct my problem.  I ultimately solved the problem myself but I wanted to give you points for at least trying to help me.  You were the only one that chimed in.  Thank you for your help.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question