E
ewcummings
Guest
Hi.
Im quite new to C#, coming from a Cobol background. I am in the process of converting ALL our hospitals Cobol-based systems to .NET using C#.
Ive just come up against a brick-wall, so-to-speak, wherein I need to display patient info. in a SINGLE dataGridView from 2 different sqlserver tables which are accessed using 2 different sqlserver connection strings.
I am using a sqlServerDataAdapter for one of the queries as follows:
sqlConnection adtConn;
sqlConnection prsConn;
adtConn.Open(); /* connect to adt database */
prsConn.Open(); /* connect to prs database */
string sqlText = "select DOB as dob,";
sqlText += " Sex as sex,";
sqlText += " ADMIT_DATE as admitDate";
sqlText += " FAMILY_NAME as FamilyName,";
sqlText += " FIRST_NAME as FirstName ";
sqlText += " from dbo.INHOUSE_D where PATIENTNO = " + strPatNo + "";
/* columns FAMILY_NAME & FIRST_NAME belong to table PATIENT_D1 in connection prsConn, while the other columns belong to table INHOUSE_D in connection adtConn */
try
{
SqlDataAdapter DAdapter = new SqlDataAdapter(sqlText, adtConn);
DataTable DTable = new DataTable();
DAdapter.Fill(DTable);
dgView.DataSource = DTable; /* Bind the dataGridView object to the dataTable.. */
}
catch (Exception ex)
{
throw new Exception("patSysManagerPswdMaint: Data Binding error detected! " + ex.Message);
}
finally
{
// Configure the details DataGridView so that its columns automatically
// adjust their widths when the data changes.
dgView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;
}
My problem is how to display data from the prsConn connection when the dataGridView is being bound using the adtConn connection?
Im SURE someone has come across this problem before. Any help would be GREATLY appreciated!
Thanks!.
Continue reading...
Im quite new to C#, coming from a Cobol background. I am in the process of converting ALL our hospitals Cobol-based systems to .NET using C#.
Ive just come up against a brick-wall, so-to-speak, wherein I need to display patient info. in a SINGLE dataGridView from 2 different sqlserver tables which are accessed using 2 different sqlserver connection strings.
I am using a sqlServerDataAdapter for one of the queries as follows:
sqlConnection adtConn;
sqlConnection prsConn;
adtConn.Open(); /* connect to adt database */
prsConn.Open(); /* connect to prs database */
string sqlText = "select DOB as dob,";
sqlText += " Sex as sex,";
sqlText += " ADMIT_DATE as admitDate";
sqlText += " FAMILY_NAME as FamilyName,";
sqlText += " FIRST_NAME as FirstName ";
sqlText += " from dbo.INHOUSE_D where PATIENTNO = " + strPatNo + "";
/* columns FAMILY_NAME & FIRST_NAME belong to table PATIENT_D1 in connection prsConn, while the other columns belong to table INHOUSE_D in connection adtConn */
try
{
SqlDataAdapter DAdapter = new SqlDataAdapter(sqlText, adtConn);
DataTable DTable = new DataTable();
DAdapter.Fill(DTable);
dgView.DataSource = DTable; /* Bind the dataGridView object to the dataTable.. */
}
catch (Exception ex)
{
throw new Exception("patSysManagerPswdMaint: Data Binding error detected! " + ex.Message);
}
finally
{
// Configure the details DataGridView so that its columns automatically
// adjust their widths when the data changes.
dgView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells;
}
My problem is how to display data from the prsConn connection when the dataGridView is being bound using the adtConn connection?
Im SURE someone has come across this problem before. Any help would be GREATLY appreciated!
Thanks!.
Continue reading...