PC Review


Reply
Thread Tools Rate Thread

Debug skips DataAdapter.Update code. Why??

 
 
Assimalyst
Guest
Posts: n/a
 
      28th Jul 2005
Hi,

I'm attempting to input data into two related tables using stored
procedures. I found some good example code, which i have followed,
checked and double checked, but for some reason the update is not
happening.

Below is the code, it's pretty lengthy so to save you time i'll say now
that it runs through fine in debug until near the very end, the
patientDataAdapter.Update(dsAddPatient, "Patient"); line just above the
'catch' section. It runs the previous line then jumps this and
subsequent lines going straight to 'catch'.

The code:

private void addPatientDataToDB()
{
try
{
// Create the DataSet object
DataSet dsAddPatient = new DataSet();
// Connect to database
SqlConnection conn = new
SqlConnection(ConfigurationSettings.AppSettings["strConn"]);
conn.Open();

// Create the DataTable "Patient" in the Dataset and the
DataAdapter
SqlDataAdapter patientDataAdapter = new
SqlDataAdapter(new SqlCommand("SELECT * FROM tblPatient", conn));

patientDataAdapter.InsertCommand = new
SqlCommand("proc_InsertPatient", conn);
SqlCommand cmdInsert = patientDataAdapter.InsertCommand;
cmdInsert.CommandType = CommandType.StoredProcedure;

cmdInsert.Parameters.Add(new SqlParameter("@patientNo",
SqlDbType.Int));
cmdInsert.Parameters["@patientNo"].Direction =
ParameterDirection.Output;
cmdInsert.Parameters["@patientNo"].SourceColumn = "patientNo";

cmdInsert.Parameters.Add(new SqlParameter("@pntUnitID",
SqlDbType.NVarChar,15,"pntUnitID"));
cmdInsert.Parameters.Add(new SqlParameter("@pntTitle",
SqlDbType.NVarChar,4,"pntTitle"));
cmdInsert.Parameters.Add(new SqlParameter("@pntFName",
SqlDbType.NVarChar,20,"pntFName"));
cmdInsert.Parameters.Add(new SqlParameter("@pntLName",
SqlDbType.NVarChar,30,"pntLName"));
cmdInsert.Parameters.Add(new SqlParameter("@pntDOB",
SqlDbType.DateTime,8,"pntDOB"));
cmdInsert.Parameters.Add(new SqlParameter("@pntSex",
SqlDbType.NVarChar,1,"pntSex"));
cmdInsert.Parameters.Add(new SqlParameter("@pntAddress1",
SqlDbType.NVarChar,150,"pntAddress1"));
cmdInsert.Parameters.Add(new SqlParameter("@pntAddress2",
SqlDbType.NVarChar,150,"pntAddress2"));
cmdInsert.Parameters.Add(new SqlParameter("@pntAddress3",
SqlDbType.NVarChar,150,"pntAddress3"));
cmdInsert.Parameters.Add(new SqlParameter("@pntcountryNo",
SqlDbType.Int,4,"pntCountryNo"));
cmdInsert.Parameters.Add(new SqlParameter("@pntPostcode",
SqlDbType.NVarChar,10,"pntPostcode"));
cmdInsert.Parameters.Add(new SqlParameter("@pntHPnone",
SqlDbType.NVarChar,14,"pntHPnone"));
cmdInsert.Parameters.Add(new SqlParameter("@pntWPhone",
SqlDbType.NVarChar,14,"pntWPhone"));
cmdInsert.Parameters.Add(new SqlParameter("@pntMobPhone",
SqlDbType.NVarChar,14,"pntMobPhone"));
cmdInsert.Parameters.Add(new SqlParameter("@pntEmail",
SqlDbType.NVarChar,50,"pntEmail"));
cmdInsert.Parameters.Add(new SqlParameter("@pntStage",
SqlDbType.NVarChar,5,"pntStage"));
cmdInsert.Parameters.Add(new SqlParameter("@pntT",
SqlDbType.TinyInt,1,"pntT"));
cmdInsert.Parameters.Add(new SqlParameter("@pntN",
SqlDbType.TinyInt,1,"pntN"));
cmdInsert.Parameters.Add(new SqlParameter("@pntM",
SqlDbType.TinyInt,1,"pntM"));
cmdInsert.Parameters.Add(new SqlParameter("@pntPreviousTreatments",
SqlDbType.Char,1000,"pntPreviousTreatments"));
cmdInsert.Parameters.Add(new SqlParameter("@pntFurtherNotes",
SqlDbType.Char,1000,"pntFurtherNotes"));

patientDataAdapter.FillSchema(dsAddPatient, SchemaType.Source);

DataTable pTable = dsAddPatient.Tables["Table"];
pTable.TableName = "Patient";

// Create the DataTable "Histology" in the
// Dataset and the DataAdapter

SqlDataAdapter histologyDataAdapter = new
SqlDataAdapter(new SqlCommand("SELECT * FROM tblSample", conn));

histologyDataAdapter.InsertCommand = new
SqlCommand("proc_InsertHistology", conn);

cmdInsert = histologyDataAdapter.InsertCommand;
cmdInsert.CommandType = CommandType.StoredProcedure;

cmdInsert.Parameters.Add(new SqlParameter("@patientNo",
SqlDbType.Int,4));
cmdInsert.Parameters["@patientNo"].SourceColumn = "patientNo";
cmdInsert.Parameters.Add(new SqlParameter("@lesHistology",
SqlDbType.NVarChar,50));
cmdInsert.Parameters["@lesHistology"].SourceColumn =
"lesHistology";
cmdInsert.Parameters.Add(new SqlParameter("@lesNull",
SqlDbType.NVarChar,10));
cmdInsert.Parameters["@lesNull"].SourceColumn = "lesNull";

histologyDataAdapter.FillSchema(dsAddPatient, SchemaType.Source);

pTable = dsAddPatient.Tables["Table"];
pTable.TableName = "Histology";

// Create the relationship between the two tables
dsAddPatient.Relations.Add(new DataRelation("ParentChild",
dsAddPatient.Tables["Patient"].Columns["patientNo"],
dsAddPatient.Tables["Histology"].Columns["patientNo"]));

// Insert the Data
DataRow patientRow = dsAddPatient.Tables["Patient"].NewRow();
patientRow["pntUnitID"] = patientCodeTxtBx.Text;
patientRow["pntTitle"] = titleCboBx.SelectedValue;
patientRow["pntFName"] = fNameTxtBx.Text;
patientRow["pntLName"] = lNameTxtBx.Text;
patientRow["pntSex"] = sexCboBx.SelectedValue;
patientRow["pntDOB"] = DOBTxtBx.Text;
patientRow["pntAddress1"] = address1TxtBx.Text;
patientRow["pntAddress2"] = address2TxtBx.Text;
patientRow["pntAddress3"] = address3TxtBx.Text;
patientRow["pntcountryNo"] = countryCboBx.SelectedValue;
patientRow["pntPostcode"] = postcodeTxtBx.Text;
patientRow["pntHPhone"] = phoneTxtBx.Text;
patientRow["pntWPhone"] = workPhoneTxtBx.Text;
patientRow["pntMobPhone"] = mobileTxtBx.Text;
patientRow["pntEmail"] = emailTxtBx.Text;
patientRow["pntStage"] = stageCboBx.SelectedValue;
patientRow["pntT"] = tTxtBx.Text;
patientRow["pntN"] = nTxtBx.Text;
patientRow["pntM"] = mTxtBx.Text;
patientRow["pntPreviousTreatments"] = previousTreatmentsTxtBx.Text;
patientRow["pntFurtherNotes"] = notesTxtBx.Text;
dsAddPatient.Tables["Patient"].Rows.Add(patientRow);

DataRow histologyRow = dsAddPatient.Tables["Histology"].NewRow();
histologyRow["lesHistology"] = histologyCboBx.SelectedValue;

histologyRow.SetParentRow(patientRow);
dsAddPatient.Tables["Histology"].Rows.Add(histologyRow);

patientDataAdapter.Update(dsAddPatient, "Patient");
histologyDataAdapter.Update(dsAddPatient, "Histology");

messageLbl.Text = "Data successfully added to database";
}
catch (Exception ex)
{
messageLbl.Text = ex + "Unable to connect to the database";
}
finally
{
// Close the connection
DataAccess.DBConnection.CloseDBConnection();
}
}

Anyone with any ideas why it might be jumping the

patientDataAdapter.Update(dsAddPatient, "Patient");
and
histologyDataAdapter.Update(dsAddPatient, "Histology");

statements?

Thanks.

 
Reply With Quote
 
 
 
 
Marina
Guest
Posts: n/a
 
      28th Jul 2005
That is because the line above the Update is causing an error. Hence, the
debugger is going to the next line that gets executed - the catch clause.

You should look at 'ex' to see what the problems is.

"Assimalyst" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi,
>
> I'm attempting to input data into two related tables using stored
> procedures. I found some good example code, which i have followed,
> checked and double checked, but for some reason the update is not
> happening.
>
> Below is the code, it's pretty lengthy so to save you time i'll say now
> that it runs through fine in debug until near the very end, the
> patientDataAdapter.Update(dsAddPatient, "Patient"); line just above the
> 'catch' section. It runs the previous line then jumps this and
> subsequent lines going straight to 'catch'.
>
> The code:
>
> private void addPatientDataToDB()
> {
> try
> {
> // Create the DataSet object
> DataSet dsAddPatient = new DataSet();
> // Connect to database
> SqlConnection conn = new
> SqlConnection(ConfigurationSettings.AppSettings["strConn"]);
> conn.Open();
>
> // Create the DataTable "Patient" in the Dataset and the
> DataAdapter
> SqlDataAdapter patientDataAdapter = new
> SqlDataAdapter(new SqlCommand("SELECT * FROM tblPatient", conn));
>
> patientDataAdapter.InsertCommand = new
> SqlCommand("proc_InsertPatient", conn);
> SqlCommand cmdInsert = patientDataAdapter.InsertCommand;
> cmdInsert.CommandType = CommandType.StoredProcedure;
>
> cmdInsert.Parameters.Add(new SqlParameter("@patientNo",
> SqlDbType.Int));
> cmdInsert.Parameters["@patientNo"].Direction =
> ParameterDirection.Output;
> cmdInsert.Parameters["@patientNo"].SourceColumn = "patientNo";
>
> cmdInsert.Parameters.Add(new SqlParameter("@pntUnitID",
> SqlDbType.NVarChar,15,"pntUnitID"));
> cmdInsert.Parameters.Add(new SqlParameter("@pntTitle",
> SqlDbType.NVarChar,4,"pntTitle"));
> cmdInsert.Parameters.Add(new SqlParameter("@pntFName",
> SqlDbType.NVarChar,20,"pntFName"));
> cmdInsert.Parameters.Add(new SqlParameter("@pntLName",
> SqlDbType.NVarChar,30,"pntLName"));
> cmdInsert.Parameters.Add(new SqlParameter("@pntDOB",
> SqlDbType.DateTime,8,"pntDOB"));
> cmdInsert.Parameters.Add(new SqlParameter("@pntSex",
> SqlDbType.NVarChar,1,"pntSex"));
> cmdInsert.Parameters.Add(new SqlParameter("@pntAddress1",
> SqlDbType.NVarChar,150,"pntAddress1"));
> cmdInsert.Parameters.Add(new SqlParameter("@pntAddress2",
> SqlDbType.NVarChar,150,"pntAddress2"));
> cmdInsert.Parameters.Add(new SqlParameter("@pntAddress3",
> SqlDbType.NVarChar,150,"pntAddress3"));
> cmdInsert.Parameters.Add(new SqlParameter("@pntcountryNo",
> SqlDbType.Int,4,"pntCountryNo"));
> cmdInsert.Parameters.Add(new SqlParameter("@pntPostcode",
> SqlDbType.NVarChar,10,"pntPostcode"));
> cmdInsert.Parameters.Add(new SqlParameter("@pntHPnone",
> SqlDbType.NVarChar,14,"pntHPnone"));
> cmdInsert.Parameters.Add(new SqlParameter("@pntWPhone",
> SqlDbType.NVarChar,14,"pntWPhone"));
> cmdInsert.Parameters.Add(new SqlParameter("@pntMobPhone",
> SqlDbType.NVarChar,14,"pntMobPhone"));
> cmdInsert.Parameters.Add(new SqlParameter("@pntEmail",
> SqlDbType.NVarChar,50,"pntEmail"));
> cmdInsert.Parameters.Add(new SqlParameter("@pntStage",
> SqlDbType.NVarChar,5,"pntStage"));
> cmdInsert.Parameters.Add(new SqlParameter("@pntT",
> SqlDbType.TinyInt,1,"pntT"));
> cmdInsert.Parameters.Add(new SqlParameter("@pntN",
> SqlDbType.TinyInt,1,"pntN"));
> cmdInsert.Parameters.Add(new SqlParameter("@pntM",
> SqlDbType.TinyInt,1,"pntM"));
> cmdInsert.Parameters.Add(new SqlParameter("@pntPreviousTreatments",
> SqlDbType.Char,1000,"pntPreviousTreatments"));
> cmdInsert.Parameters.Add(new SqlParameter("@pntFurtherNotes",
> SqlDbType.Char,1000,"pntFurtherNotes"));
>
> patientDataAdapter.FillSchema(dsAddPatient, SchemaType.Source);
>
> DataTable pTable = dsAddPatient.Tables["Table"];
> pTable.TableName = "Patient";
>
> // Create the DataTable "Histology" in the
> // Dataset and the DataAdapter
>
> SqlDataAdapter histologyDataAdapter = new
> SqlDataAdapter(new SqlCommand("SELECT * FROM tblSample", conn));
>
> histologyDataAdapter.InsertCommand = new
> SqlCommand("proc_InsertHistology", conn);
>
> cmdInsert = histologyDataAdapter.InsertCommand;
> cmdInsert.CommandType = CommandType.StoredProcedure;
>
> cmdInsert.Parameters.Add(new SqlParameter("@patientNo",
> SqlDbType.Int,4));
> cmdInsert.Parameters["@patientNo"].SourceColumn = "patientNo";
> cmdInsert.Parameters.Add(new SqlParameter("@lesHistology",
> SqlDbType.NVarChar,50));
> cmdInsert.Parameters["@lesHistology"].SourceColumn =
> "lesHistology";
> cmdInsert.Parameters.Add(new SqlParameter("@lesNull",
> SqlDbType.NVarChar,10));
> cmdInsert.Parameters["@lesNull"].SourceColumn = "lesNull";
>
> histologyDataAdapter.FillSchema(dsAddPatient, SchemaType.Source);
>
> pTable = dsAddPatient.Tables["Table"];
> pTable.TableName = "Histology";
>
> // Create the relationship between the two tables
> dsAddPatient.Relations.Add(new DataRelation("ParentChild",
> dsAddPatient.Tables["Patient"].Columns["patientNo"],
> dsAddPatient.Tables["Histology"].Columns["patientNo"]));
>
> // Insert the Data
> DataRow patientRow = dsAddPatient.Tables["Patient"].NewRow();
> patientRow["pntUnitID"] = patientCodeTxtBx.Text;
> patientRow["pntTitle"] = titleCboBx.SelectedValue;
> patientRow["pntFName"] = fNameTxtBx.Text;
> patientRow["pntLName"] = lNameTxtBx.Text;
> patientRow["pntSex"] = sexCboBx.SelectedValue;
> patientRow["pntDOB"] = DOBTxtBx.Text;
> patientRow["pntAddress1"] = address1TxtBx.Text;
> patientRow["pntAddress2"] = address2TxtBx.Text;
> patientRow["pntAddress3"] = address3TxtBx.Text;
> patientRow["pntcountryNo"] = countryCboBx.SelectedValue;
> patientRow["pntPostcode"] = postcodeTxtBx.Text;
> patientRow["pntHPhone"] = phoneTxtBx.Text;
> patientRow["pntWPhone"] = workPhoneTxtBx.Text;
> patientRow["pntMobPhone"] = mobileTxtBx.Text;
> patientRow["pntEmail"] = emailTxtBx.Text;
> patientRow["pntStage"] = stageCboBx.SelectedValue;
> patientRow["pntT"] = tTxtBx.Text;
> patientRow["pntN"] = nTxtBx.Text;
> patientRow["pntM"] = mTxtBx.Text;
> patientRow["pntPreviousTreatments"] = previousTreatmentsTxtBx.Text;
> patientRow["pntFurtherNotes"] = notesTxtBx.Text;
> dsAddPatient.Tables["Patient"].Rows.Add(patientRow);
>
> DataRow histologyRow = dsAddPatient.Tables["Histology"].NewRow();
> histologyRow["lesHistology"] = histologyCboBx.SelectedValue;
>
> histologyRow.SetParentRow(patientRow);
> dsAddPatient.Tables["Histology"].Rows.Add(histologyRow);
>
> patientDataAdapter.Update(dsAddPatient, "Patient");
> histologyDataAdapter.Update(dsAddPatient, "Histology");
>
> messageLbl.Text = "Data successfully added to database";
> }
> catch (Exception ex)
> {
> messageLbl.Text = ex + "Unable to connect to the database";
> }
> finally
> {
> // Close the connection
> DataAccess.DBConnection.CloseDBConnection();
> }
> }
>
> Anyone with any ideas why it might be jumping the
>
> patientDataAdapter.Update(dsAddPatient, "Patient");
> and
> histologyDataAdapter.Update(dsAddPatient, "Histology");
>
> statements?
>
> Thanks.
>



 
Reply With Quote
 
Jerry H.
Guest
Posts: n/a
 
      28th Jul 2005
Can you tell us what is the error returned in the Message property of
the Ex object from your Catch section?

Right now, you always return "Unable to connect to Database", but in
fact any number of things could go wrong which may have nothing to do
with a connection problem.

 
Reply With Quote
 
Patrice
Guest
Posts: n/a
 
      28th Jul 2005
Do you know what try/catch does ? Now that you have an exception see its
details to diagnose the problem or post its details to get help ???

--
Patrice

"Assimalyst" <(E-Mail Removed)> a écrit dans le message de
news:(E-Mail Removed)...
> Hi,
>
> I'm attempting to input data into two related tables using stored
> procedures. I found some good example code, which i have followed,
> checked and double checked, but for some reason the update is not
> happening.
>
> Below is the code, it's pretty lengthy so to save you time i'll say now
> that it runs through fine in debug until near the very end, the
> patientDataAdapter.Update(dsAddPatient, "Patient"); line just above the
> 'catch' section. It runs the previous line then jumps this and
> subsequent lines going straight to 'catch'.
>
> The code:
>
> private void addPatientDataToDB()
> {
> try
> {
> // Create the DataSet object
> DataSet dsAddPatient = new DataSet();
> // Connect to database
> SqlConnection conn = new
> SqlConnection(ConfigurationSettings.AppSettings["strConn"]);
> conn.Open();
>
> // Create the DataTable "Patient" in the Dataset and the
> DataAdapter
> SqlDataAdapter patientDataAdapter = new
> SqlDataAdapter(new SqlCommand("SELECT * FROM tblPatient", conn));
>
> patientDataAdapter.InsertCommand = new
> SqlCommand("proc_InsertPatient", conn);
> SqlCommand cmdInsert = patientDataAdapter.InsertCommand;
> cmdInsert.CommandType = CommandType.StoredProcedure;
>
> cmdInsert.Parameters.Add(new SqlParameter("@patientNo",
> SqlDbType.Int));
> cmdInsert.Parameters["@patientNo"].Direction =
> ParameterDirection.Output;
> cmdInsert.Parameters["@patientNo"].SourceColumn = "patientNo";
>
> cmdInsert.Parameters.Add(new SqlParameter("@pntUnitID",
> SqlDbType.NVarChar,15,"pntUnitID"));
> cmdInsert.Parameters.Add(new SqlParameter("@pntTitle",
> SqlDbType.NVarChar,4,"pntTitle"));
> cmdInsert.Parameters.Add(new SqlParameter("@pntFName",
> SqlDbType.NVarChar,20,"pntFName"));
> cmdInsert.Parameters.Add(new SqlParameter("@pntLName",
> SqlDbType.NVarChar,30,"pntLName"));
> cmdInsert.Parameters.Add(new SqlParameter("@pntDOB",
> SqlDbType.DateTime,8,"pntDOB"));
> cmdInsert.Parameters.Add(new SqlParameter("@pntSex",
> SqlDbType.NVarChar,1,"pntSex"));
> cmdInsert.Parameters.Add(new SqlParameter("@pntAddress1",
> SqlDbType.NVarChar,150,"pntAddress1"));
> cmdInsert.Parameters.Add(new SqlParameter("@pntAddress2",
> SqlDbType.NVarChar,150,"pntAddress2"));
> cmdInsert.Parameters.Add(new SqlParameter("@pntAddress3",
> SqlDbType.NVarChar,150,"pntAddress3"));
> cmdInsert.Parameters.Add(new SqlParameter("@pntcountryNo",
> SqlDbType.Int,4,"pntCountryNo"));
> cmdInsert.Parameters.Add(new SqlParameter("@pntPostcode",
> SqlDbType.NVarChar,10,"pntPostcode"));
> cmdInsert.Parameters.Add(new SqlParameter("@pntHPnone",
> SqlDbType.NVarChar,14,"pntHPnone"));
> cmdInsert.Parameters.Add(new SqlParameter("@pntWPhone",
> SqlDbType.NVarChar,14,"pntWPhone"));
> cmdInsert.Parameters.Add(new SqlParameter("@pntMobPhone",
> SqlDbType.NVarChar,14,"pntMobPhone"));
> cmdInsert.Parameters.Add(new SqlParameter("@pntEmail",
> SqlDbType.NVarChar,50,"pntEmail"));
> cmdInsert.Parameters.Add(new SqlParameter("@pntStage",
> SqlDbType.NVarChar,5,"pntStage"));
> cmdInsert.Parameters.Add(new SqlParameter("@pntT",
> SqlDbType.TinyInt,1,"pntT"));
> cmdInsert.Parameters.Add(new SqlParameter("@pntN",
> SqlDbType.TinyInt,1,"pntN"));
> cmdInsert.Parameters.Add(new SqlParameter("@pntM",
> SqlDbType.TinyInt,1,"pntM"));
> cmdInsert.Parameters.Add(new SqlParameter("@pntPreviousTreatments",
> SqlDbType.Char,1000,"pntPreviousTreatments"));
> cmdInsert.Parameters.Add(new SqlParameter("@pntFurtherNotes",
> SqlDbType.Char,1000,"pntFurtherNotes"));
>
> patientDataAdapter.FillSchema(dsAddPatient, SchemaType.Source);
>
> DataTable pTable = dsAddPatient.Tables["Table"];
> pTable.TableName = "Patient";
>
> // Create the DataTable "Histology" in the
> // Dataset and the DataAdapter
>
> SqlDataAdapter histologyDataAdapter = new
> SqlDataAdapter(new SqlCommand("SELECT * FROM tblSample", conn));
>
> histologyDataAdapter.InsertCommand = new
> SqlCommand("proc_InsertHistology", conn);
>
> cmdInsert = histologyDataAdapter.InsertCommand;
> cmdInsert.CommandType = CommandType.StoredProcedure;
>
> cmdInsert.Parameters.Add(new SqlParameter("@patientNo",
> SqlDbType.Int,4));
> cmdInsert.Parameters["@patientNo"].SourceColumn = "patientNo";
> cmdInsert.Parameters.Add(new SqlParameter("@lesHistology",
> SqlDbType.NVarChar,50));
> cmdInsert.Parameters["@lesHistology"].SourceColumn =
> "lesHistology";
> cmdInsert.Parameters.Add(new SqlParameter("@lesNull",
> SqlDbType.NVarChar,10));
> cmdInsert.Parameters["@lesNull"].SourceColumn = "lesNull";
>
> histologyDataAdapter.FillSchema(dsAddPatient, SchemaType.Source);
>
> pTable = dsAddPatient.Tables["Table"];
> pTable.TableName = "Histology";
>
> // Create the relationship between the two tables
> dsAddPatient.Relations.Add(new DataRelation("ParentChild",
> dsAddPatient.Tables["Patient"].Columns["patientNo"],
> dsAddPatient.Tables["Histology"].Columns["patientNo"]));
>
> // Insert the Data
> DataRow patientRow = dsAddPatient.Tables["Patient"].NewRow();
> patientRow["pntUnitID"] = patientCodeTxtBx.Text;
> patientRow["pntTitle"] = titleCboBx.SelectedValue;
> patientRow["pntFName"] = fNameTxtBx.Text;
> patientRow["pntLName"] = lNameTxtBx.Text;
> patientRow["pntSex"] = sexCboBx.SelectedValue;
> patientRow["pntDOB"] = DOBTxtBx.Text;
> patientRow["pntAddress1"] = address1TxtBx.Text;
> patientRow["pntAddress2"] = address2TxtBx.Text;
> patientRow["pntAddress3"] = address3TxtBx.Text;
> patientRow["pntcountryNo"] = countryCboBx.SelectedValue;
> patientRow["pntPostcode"] = postcodeTxtBx.Text;
> patientRow["pntHPhone"] = phoneTxtBx.Text;
> patientRow["pntWPhone"] = workPhoneTxtBx.Text;
> patientRow["pntMobPhone"] = mobileTxtBx.Text;
> patientRow["pntEmail"] = emailTxtBx.Text;
> patientRow["pntStage"] = stageCboBx.SelectedValue;
> patientRow["pntT"] = tTxtBx.Text;
> patientRow["pntN"] = nTxtBx.Text;
> patientRow["pntM"] = mTxtBx.Text;
> patientRow["pntPreviousTreatments"] = previousTreatmentsTxtBx.Text;
> patientRow["pntFurtherNotes"] = notesTxtBx.Text;
> dsAddPatient.Tables["Patient"].Rows.Add(patientRow);
>
> DataRow histologyRow = dsAddPatient.Tables["Histology"].NewRow();
> histologyRow["lesHistology"] = histologyCboBx.SelectedValue;
>
> histologyRow.SetParentRow(patientRow);
> dsAddPatient.Tables["Histology"].Rows.Add(histologyRow);
>
> patientDataAdapter.Update(dsAddPatient, "Patient");
> histologyDataAdapter.Update(dsAddPatient, "Histology");
>
> messageLbl.Text = "Data successfully added to database";
> }
> catch (Exception ex)
> {
> messageLbl.Text = ex + "Unable to connect to the database";
> }
> finally
> {
> // Close the connection
> DataAccess.DBConnection.CloseDBConnection();
> }
> }
>
> Anyone with any ideas why it might be jumping the
>
> patientDataAdapter.Update(dsAddPatient, "Patient");
> and
> histologyDataAdapter.Update(dsAddPatient, "Histology");
>
> statements?
>
> Thanks.
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Code skips refresh all F Jones Microsoft Excel Discussion 5 24th Apr 2008 06:20 PM
This dataAdapter update code keeps timing out... Bmack500 Microsoft ADO .NET 0 14th Sep 2006 05:11 PM
What's wrong with this dataadapter update code? Bmack500 Microsoft ADO .NET 1 30th Jun 2006 03:55 PM
How to tell if your C# code is running in debug mode (debug compil =?Utf-8?B?TWF4IE0uIFBvd2Vy?= Microsoft C# .NET 3 20th Oct 2005 10:39 PM
How best to update DataAdapter to make DataGrid update immediately like table in Access would John Edens Microsoft Dot NET Framework Forms 1 5th Aug 2005 07:44 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:43 PM.