Solved

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

Posted on 2008-10-23
3
2,742 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
  • 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
COnsume rest client 6 36
Programmatically signing Word macros 4 61
Error when loading the database 16 54
Turn on intranet settings 1 36
Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

919 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now