Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7579215
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T17:37:17+00:00 2026-05-30T17:37:17+00:00

I have Linq-to-SQL code here which submits data into the database in their respective

  • 0

I have Linq-to-SQL code here which submits data into the database in their respective table,
PatientInformation and ResponsibleParty:

public void addPatientInformation() { 
   using(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;

      myDb.PatientInfos.InsertOnSubmit(patientInfo);
      myDb.SubmitChanges();
   }
}

public void addResponsiblePartyInformation() { 
   using(DbClassesDataContext myDb = new DbClassesDataContext(dbPath)){
      ResponsibleParty responsibleParty = new ResponsibleParty();

      responsibleParty.Res_First_Name = txtResFirstName.Text;
      responsibleParty.Res_Middle_Init = txtResMiddleName.Text;
      responsibleParty.Res_Last_Name = txtResLName.Text;
      responsibleParty.Res_Gender = cmbResGender.Text;
      responsibleParty.Res_Marital_Status = cmbResMaritalStatus.Text;
      responsibleParty.Res_Date_Of_Birth = dtpResDOB.Value;
      responsibleParty.Res_Home_Add = txtResHomeAdd.Text;
      responsibleParty.Res_Home_Num = txtResPhone.Text;
      responsibleParty.Res_Work_Add = txtResWorkAdd.Text;
      responsibleParty.Res_Work_Num = txtResWorkPhone.Text;

      myDb.ResponsibleParties.InsertOnSubmit(responsibleParty);
      myDb.SubmitChanges();
   }

And a method named

public void submitInformationToDatabase() {
            addPatientInformation();
            addResponsiblePartyInformation();
            MessageBox.Show("Patient Demographics Has Been added.");
        }

Is there a way I could submit them at once?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T17:37:19+00:00Added an answer on May 30, 2026 at 5:37 pm

    If you can refactor your code to something resembling the example below, then both records will be inserted in the same submit.

    using(DbClassesDataContext myDb = new DbClassesDataContext(dbPath)){
    
          myDb.PatientInfos.InsertOnSubmit(patientInfo);
          myDb.ResponsibleParties.InsertOnSubmit(responsibleParty);
          myDb.SubmitChanges();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a WPF C# Application which is accessing data through a SQL-LINQ connection
I have some e-commerce code that I use often that uses Linq To SQL
What I have: LINQ to SQL auto generated class, which corresponds to the shape
I have a linq to sql database. Very simplified we have 3 tables, Projects
I have a LINQ to SQL class VoucherRecord based on a simple table. One
I need help re-factoring this legacy LINQ-SQL code which is generating around 100 update
We have a project using LINQ to SQL, for which I need to rewrite
Here is simplified SQL of my tables, which is converted to LINQ to SQL
I have compared two queries which fetch some fairly large data from a database
I have created small test web application which makes use of LINQ to SQL.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.