473,395 Members | 1,442 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Updating related records in SQL Server, C#, Visual Studio .Net 2k3

Hopefully someone here can help me/point me in the right direction.
I've found tons of references towards making relations, creating rows,
saving said rows, using datagrids, databinding objects, and etc in
regards to Windows Forms, C#, and Visual Studio .Net 2003.

I seem to have run into a bit of a problem however. I'm not using
datagrids to show related data, my users wouldn't have any idea how to
use them, and they want to see all of their information in the same
place (So they don't want to see a Customer ID number when they are
looking at an order - They want to see that customer's Name). As such
I've created a form with 4 tabs in a TabControl, each tab shows the
related table's data (Shipment Profile, Dangerous Goods, Notes,
Products Used). The tabs use Combo boxes, Text Boxes, etc to show the
important fields. I have a dataset that is filled at runtime. This
dataset also has all the relations defined (parent and child tables are
linked by QuoteID field). The tables in the dataset are filling. The
relations (QuotesShipmentProfile, QuotesDGs, QuotesNotes,
QuotesProductsUsedInQuotes) seem to be working/defined. However, the
databinding seems off when I switch between rows and if I create
new/modify old/delete rows (in the parent tables [Quotes] and/or the
child tables [ShipmentProfile, DG, Notes, ProductsUsedInQuotes]), the
Update commands fail and nothing is written to the SQL Server. I
assume this is due to the binding as well.

Follows is a small part of my code. If you want to see more, just let
me know.
Thanks,
Beth

On Form Load:
//sql stuff
private ClassicLogistics.DatasetCL objDataSet;
private ClassicLogistics.DatasetCL objDataSet2;
private System.Data.SqlClient.SqlConnection cl;
private System.Data.SqlClient.SqlDataAdapter
HAWBTableAdapter;
private System.Data.SqlClient.SqlCommandBuilder HAWBCom;
private System.Data.SqlClient.SqlDataAdapter
DimTableAdapter;
private System.Data.SqlClient.SqlCommandBuilder DimCom;
private System.Data.SqlClient.SqlDataAdapter
DGTableAdapter;
private System.Data.SqlClient.SqlCommandBuilder DGCom;
private System.Data.SqlClient.SqlDataAdapter
NoteTableAdapter;
private System.Data.SqlClient.SqlCommandBuilder NoteCom;
private System.Data.SqlClient.SqlDataAdapter
ProdUsedTableAdapter;
private System.Data.SqlClient.SqlCommandBuilder
ProdUsedCom;
private System.Data.SqlClient.SqlCommand selectCom;
private System.Data.SqlClient.SqlCommand addCom;
private System.Data.SqlClient.SqlCommand delCom;
private System.Data.SqlClient.SqlCommand upCom;
private System.Data.SqlClient.SqlCommand DselectCom;
private System.Data.SqlClient.SqlCommand DaddCom;
private System.Data.SqlClient.SqlCommand DdelCom;
private System.Data.SqlClient.SqlCommand DupCom;
private System.Data.SqlClient.SqlCommand DGselectCom;
private System.Data.SqlClient.SqlCommand DGaddCom;
private System.Data.SqlClient.SqlCommand DGdelCom;
private System.Data.SqlClient.SqlCommand DGupCom;
private System.Data.SqlClient.SqlCommand NselectCom;
private System.Data.SqlClient.SqlCommand NaddCom;
private System.Data.SqlClient.SqlCommand NdelCom;
private System.Data.SqlClient.SqlCommand NupCom;
private System.Data.SqlClient.SqlCommand PselectCom;
private System.Data.SqlClient.SqlCommand PaddCom;
private System.Data.SqlClient.SqlCommand PdelCom;
private System.Data.SqlClient.SqlCommand PupCom;
private DataRow[] shipdet;
private DataRow[] shipprofdet;
private DataRow[] dgdet;
private DataRow[] notedet;
private DataRow[] proddet;
private int numOfRows;
private StringBuilder errorMessages;

//set up sql stuff, bind objects
objDataSet = new DatasetCL();
objDataSet2 = new DatasetCL();

//prints dataset defined relations
foreach (DataRelation r in
objDataSet.Quotes.ChildRelations)
Console.WriteLine("Name: " +
r.RelationName.ToString() + " Parent:" +

r.ParentKeyConstraint.ConstraintName.ToString() + " Child: " +

r.ChildKeyConstraint.ConstraintName.ToString());

cl = new
SqlConnection("server=SERVER1;uid=ClassicUser;Pwd= admin;database=ClassicLogisticsBE");
cl.Open();

selectCom = cl.CreateCommand();
selectCom.CommandText = "SELECT QuoteID, HAWB,
CustomerID, " +
"CustomerContact, EnteredBy, QuoteDate,
OriginZip, " +
"DestinationZip, Commodity,
RecoveryDate, ShipperID, "+
"ConsigneeID, CustomerRef, CarrierID,
Pieces, ActWgt, " +
"ChgWgt, Charge, Cost, MAWB, ManifestNo,
DeliveryDate, " +
"DropOrder, DriverNote, OnHandNo,
RateConfirmCheck, " +
"CompleteCheck, Cancel FROM Quotes ORDER
BY QuoteID";

addCom = cl.CreateCommand();
addCom.CommandText = "INSERT INTO Quotes ( " +
"HAWB, CustomerID, CustomerContact,
EnteredBy, " +
"QuoteDate, OriginZip, DestinationZip,
Commodity, " +
"RecoveryDate, ShipperID, ConsigneeID,
CustomerRef, " +
"CarrierID, Pieces, ActWgt, ChgWgt,
Charge, Cost, " +
"MAWB, ManifestNo, DeliveryDate,
DropOrder, DriverNote, " +
"OnHandNo, RateConfirmCheck,
CompleteCheck, Cancel)" +
" VALUES ( @HAWB, @CustomerID,
@CustomerContact, " +
"@EnteredBy, @QuoteDate, @OriginZip,
@DestinationZip, " +
"@Commodity, @RecoveryDate, @ShipperID,
@ConsigneeID, " +
"@CustomerRef, @CarrierID, @Pieces,
@ActWgt, @ChgWgt, " +
"@Charge, @Cost, @MAWB, @ManifestNo,
@DeliveryDate, " +
"@DropOrder, @DriverNote, @OnHandNo,
@RateConfirmCheck, " +
"@CompleteCheck, @Cancel);" +
"SELECT @QuoteID = SCOPE_IDENTITY();";
addCom.Parameters.Add("@QuoteID", SqlDbType.Int,
15, "QuoteID");
addCom.Parameters.Add("@HAWB",
SqlDbType.NVarChar, 20, "HAWB");
addCom.Parameters.Add("@CustomerID",
SqlDbType.Int, 100,
"CustomerID");
addCom.Parameters.Add("@CustomerContact",
SqlDbType.NVarChar, 100,
"CustomerContact");
addCom.Parameters.Add("@EnteredBy",
SqlDbType.Int, 100,
"EnteredBy");
addCom.Parameters.Add("@QuoteDate",
SqlDbType.SmallDateTime, 20,
"QuoteDate");
addCom.Parameters.Add("@OriginZip",
SqlDbType.NVarChar, 15,
"OriginZip");
addCom.Parameters.Add("@DestinationZip",
SqlDbType.NVarChar, 150,
"DestinationZip");
addCom.Parameters.Add("@Commodity",
SqlDbType.NVarChar, 50,
"Commodity");
addCom.Parameters.Add("@RecoveryDate",
SqlDbType.SmallDateTime, 20,
"RecoveryDate");
addCom.Parameters.Add("@ShipperID",
SqlDbType.Int, 100,
"ShipperID");
addCom.Parameters.Add("@ConsigneeID",
SqlDbType.Int, 100,
"ConsigneeID");
addCom.Parameters.Add("@CustomerRef",
SqlDbType.NVarChar, 100,
"CustomerRef");
addCom.Parameters.Add("@CarrierID",
SqlDbType.Int, 100,
"CarrierID");
addCom.Parameters.Add("@Pieces", SqlDbType.Int,
10, "Pieces");
addCom.Parameters.Add("@ActWgt",
SqlDbType.Decimal, 10, "ActWgt");
addCom.Parameters.Add("@ChgWgt",
SqlDbType.Decimal, 10, "ChgWgt");
addCom.Parameters.Add("@Charge",
SqlDbType.Money, 20, "Charge");
addCom.Parameters.Add("@Cost", SqlDbType.Money,
20, "Cost");
addCom.Parameters.Add("@MAWB",
SqlDbType.NVarChar, 20, "MAWB");
addCom.Parameters.Add("@ManifestNo",
SqlDbType.NVarChar, 100,
"ManifestNo");
addCom.Parameters.Add("@DeliveryDate",
SqlDbType.SmallDateTime, 20,
"DeliveryDate");
addCom.Parameters.Add("@DropOrder",
SqlDbType.Int, 50, "DropOrder");
addCom.Parameters.Add("@DriverNote",
SqlDbType.NText, 1000,
"DriverNote");
addCom.Parameters.Add("@OnHandNo",
SqlDbType.NVarChar, 100,
"OnHandNo");
addCom.Parameters.Add("@RateConfirmCheck",
SqlDbType.Bit, 1,
"RateConfirmCheck");
addCom.Parameters.Add("@CompleteCheck",
SqlDbType.Bit, 1,
"CompleteCheck");
addCom.Parameters.Add("@Cancel", SqlDbType.Bit,
1, "Cancel");
addCom.Parameters["@QuoteID"].Direction =
ParameterDirection.Output;

//there is also a delete and update command that follow

HAWBTableAdapter = new SqlDataAdapter();
HAWBTableAdapter.SelectCommand = selectCom;
HAWBTableAdapter.InsertCommand = addCom;
HAWBTableAdapter.UpdateCommand = upCom;
HAWBTableAdapter.DeleteCommand = delCom;
HAWBTableAdapter.ContinueUpdateOnError = true;
HAWBCom = new
SqlCommandBuilder(HAWBTableAdapter);

objDataSet.Quotes.Columns["QuoteID"].AllowDBNull
= false;

objDataSet.Quotes.Columns["QuoteID"].AutoIncrement = true;

objDataSet.Quotes.Columns["QuoteID"].AutoIncrementSeed = -1;

objDataSet.Quotes.Columns["QuoteID"].AutoIncrementStep = -1;
objDataSet.Quotes.Columns["QuoteID"].ReadOnly =
true;
objDataSet.Quotes.Columns["QuoteID"].Unique =
true;

//table is filled

//this is for the ShipmentProfile table. I created D..Coms for each
command, but those didn't work any better than the CommandBuilder,
there are similar lines of code for DG (DGKey), Notes (NotesKey), and
ProductsUsedInQuotes (PUIQKey)
DimTableAdapter = new SqlDataAdapter("SELECT *
FROM ShipmentProfile
ORDER BY QuoteID", cl);
/*DimTableAdapter = new SqlDataAdapter();
DimTableAdapter.SelectCommand = DselectCom;
DimTableAdapter.InsertCommand = DaddCom;
DimTableAdapter.DeleteCommand = DdelCom;
DimTableAdapter.UpdateCommand = DupCom;*/
DimTableAdapter.ContinueUpdateOnError = true;
DimCom = new SqlCommandBuilder(DimTableAdapter);
objDataSet.ShipmentProfile.Columns["SPKey"].AllowDBNull = false;

objDataSet.ShipmentProfile.Columns["SPKey"].AutoIncrement = true;

objDataSet.ShipmentProfile.Columns["SPKey"].AutoIncrementSeed = -1;

objDataSet.ShipmentProfile.Columns["SPKey"].AutoIncrementStep = -1;

objDataSet.ShipmentProfile.Columns["SPKey"].ReadOnly = true;

objDataSet.ShipmentProfile.Columns["SPKey"].Unique = true;

//fill those child tables

//Bind boxes
//HAWB Main
QuoteNoBox.DataBindings.Add("Text", objDataSet,
"Quotes.QuoteID");
EnteredByBox.DataBindings.Add("SelectedValue",
objDataSet,
"Quotes.EnteredBy");
DateBox.DataBindings.Add("Text", objDataSet,
"Quotes.QuoteDate");
MAWBBox.DataBindings.Add("Text", objDataSet,
"Quotes.MAWB");
CustBox.DataBindings.Add("SelectedValue",
objDataSet,
"Quotes.CustomerID");
ComBox.DataBindings.Add("Text", objDataSet,
"Quotes.Commodity");
ShipBox.DataBindings.Add("SelectedValue",
objDataSet,
"Quotes.ShipperID");
ConBox.DataBindings.Add("SelectedValue",
objDataSet,
"Quotes.ConsigneeID");
ChargeBox.DataBindings.Add("Text", objDataSet,
"Quotes.Charge");
CostBox.DataBindings.Add("Text", objDataSet,
"Quotes.Cost");
TotPcsBox.DataBindings.Add("Text", objDataSet,
"Quotes.Pieces");
TotWgtBox.DataBindings.Add("Text", objDataSet,
"Quotes.ActWgt");
TotChgBox.DataBindings.Add("Text", objDataSet,
"Quotes.ChgWgt");
RateCheck.DataBindings.Add("Checked",
objDataSet,
"Quotes.RateConfirmCheck");
CompCheck.DataBindings.Add("Checked",
objDataSet,
"Quotes.CompleteCheck");
CancelCheck.DataBindings.Add("Checked",
objDataSet,
"Quotes.Cancel");
//Dims Tab
PcsBox.DataBindings.Add("Text",
objDataSet.Quotes,
"QuotesShipmentProfile.Pieces");
LINBox.DataBindings.Add("Text",
objDataSet.Quotes,
"QuotesShipmentProfile.Length");
LCMBox.DataBindings.Add("Text",
objDataSet.Quotes,
"QuotesShipmentProfile.LengthMetric");
WINBox.DataBindings.Add("Text",
objDataSet.Quotes,
"QuotesShipmentProfile.Width");
WCMBox.DataBindings.Add("Text",
objDataSet.Quotes,
"QuotesShipmentProfile.WidthMetric");
HINBox.DataBindings.Add("Text",
objDataSet.Quotes,
"QuotesShipmentProfile.Height");
HCMBox.DataBindings.Add("Text",
objDataSet.Quotes,
"QuotesShipmentProfile.HeightMetric");
WLBBox.DataBindings.Add("Text",
objDataSet.Quotes,
"QuotesShipmentProfile.ActWgt");
WKGBox.DataBindings.Add("Text",
objDataSet.Quotes,
"QuotesShipmentProfile.ActWgtMetric");
DWLBBox.DataBindings.Add("Text",
objDataSet.Quotes,
"QuotesShipmentProfile.DimWgt");
DWKGBox.DataBindings.Add("Text",
objDataSet.Quotes,
"QuotesShipmentProfile.DimWgtMetric");
CWLBBox.DataBindings.Add("Text",
objDataSet.Quotes,
"QuotesShipmentProfile.ChgWgt");
CWKGBox.DataBindings.Add("Text",
objDataSet.Quotes,
"QuotesShipmentProfile.ChgWgtMetric");
CFBox.DataBindings.Add("Text",
objDataSet.Quotes,
"QuotesShipmentProfile.CubicFeet");
CIBox.DataBindings.Add("Text",
objDataSet.Quotes,
"QuotesShipmentProfile.CubicInches");
CMBox.DataBindings.Add("Text",
objDataSet.Quotes,
"QuotesShipmentProfile.CubicMeters");

//more binding for the rest of the tabs

cl.Close()

There is a button called Save that pushes the changes to the server.
The commented out sections do not seem to work any better than the
uncommented.
private void push()
{
//actually does push work
complete = true;
errorMessages = new StringBuilder();

cl.Open();

try
{
//checks for completeness and fills in
checkbox accordingly
if
(objDataSet.Relations["QuotesProductsUsedInQuotes"].ChildTable.Rows.Count.Equals(0))
complete = false;
if
(objDataSet.Relations["QuotesShipmentProfile"].ChildTable.Rows.Count.Equals(0))
complete = false;
if (ChargeBox.Text.Length.Equals(0))
complete = false;
if (CostBox.Text.Length.Equals(0))
complete = false;
if (ShipBox.Text.Length.Equals(0))
complete = false;
if (CustBox.Text.Length.Equals(0))
complete = false;
if (ConBox.Text.Length.Equals(0))
complete = false;
if (ComBox.Text.Length.Equals(0))
complete = false;
if (DateBox.Text.Length.Equals(0))
complete = false;
if (TotWgtBox.Text.Length.Equals(0))
complete = false;
if (TotChgBox.Text.Length.Equals(0))
complete = false;
if (TotPcsBox.Text.Length.Equals(0))
complete = false;

if (complete)
CompCheck.Checked = true;

//store new rows

//this.BindingContext[objDataSet,"Quotes"].EndCurrentEdit();

//this.BindingContext[objDataSet,"QuotesShipmentProfile"].EndCurrentEdit();

//this.BindingContext[objDataSet,"QuotesDG"].EndCurrentEdit();

//this.BindingContext[objDataSet,"QuotesNotes"].EndCurrentEdit();

//this.BindingContext[objDataSet,"QuotesProductsUsedInQuotes"].EndCurrentEdit();

maxQuoteID = (int)
objDataSet.Quotes.Rows[objDataSet.Quotes.Rows.Count-1]["QuoteID"];
numOfRows =
HAWBTableAdapter.Update(objDataSet, "Quotes");
Console.WriteLine("saved " +
numOfRows.ToString() + " rows");
numOfRows =
DimTableAdapter.Update(objDataSet,
"ShipmentProfile");
Console.WriteLine("saved " +
numOfRows.ToString() + " rows");
numOfRows =
DGTableAdapter.Update(objDataSet, "DG");
Console.WriteLine("saved " +
numOfRows.ToString() + " rows");
numOfRows =
NoteTableAdapter.Update(objDataSet, "Notes");
Console.WriteLine("saved " +
numOfRows.ToString() + " rows");
numOfRows =
ProdTableAdapter.Update(objDataSet,
"ProductsUsedInQuotes");
Console.WriteLine("saved " +
numOfRows.ToString() + " rows");

/*shipdet =
objDataSet.Quotes.Select("","",DataViewRowState.Ad ded);
Console.WriteLine("found " +
shipdet.Length + " rows");
numOfRows =
HAWBTableAdapter.Update(shipdet);
Console.WriteLine("saved " +
numOfRows.ToString() + " rows");
shipdet =
objDataSet.Quotes.Select("QuoteID " + maxQuoteID);
for (int x = 0; x < shipdet.Length; x++)
{
DataRow mySysLogRow =
objDataSet.SystemLog.NewRow();
mySysLogRow["DayTime"] =
System.DateTime.Now.ToString();
mySysLogRow["Username"] =
myuser.Username.ToString();
mySysLogRow["Message"] =
"Created in Quotes QuoteID " +
shipdet[x]["QuoteID"];

objDataSet.SystemLog.Rows.Add(mySysLogRow);
}
test =
SysTableAdapter.Update(objDataSet, "SystemLog");
Console.WriteLine("saved " +
test.ToString() + " log rows");

shipprofdet =
objDataSet.ShipmentProfile.Select("","",DataViewRo wState.Added);
Console.WriteLine("found " +
shipprofdet.Length + " rows");
numOfRows =
DimTableAdapter.Update(shipprofdet);
Console.WriteLine("saved " +
numOfRows.ToString() + " rows");
for (int x = 0; x < shipprofdet.Length;
x++)
{
DataRow mySysLogRow =
objDataSet.SystemLog.NewRow();
mySysLogRow["DayTime"] =
System.DateTime.Now.ToString();
mySysLogRow["Username"] =
myuser.Username.ToString();
mySysLogRow["Message"] =
"Created in Shipment Profile QuoteID " +
shipprofdet[x]["QuoteID"];

objDataSet.SystemLog.Rows.Add(mySysLogRow);
}
test =
SysTableAdapter.Update(objDataSet, "SystemLog");
Console.WriteLine("saved " +
test.ToString() + " log rows");

dgdet =
objDataSet.DG.Select("","",DataViewRowState.Added) ;
Console.WriteLine("found " +
dgdet.Length + " rows");
numOfRows =
DGTableAdapter.Update(dgdet);
Console.WriteLine("saved " +
numOfRows.ToString() + " rows");
for (int x = 0; x < dgdet.Length; x++)
{
DataRow mySysLogRow =
objDataSet.SystemLog.NewRow();
mySysLogRow["DayTime"] =
System.DateTime.Now.ToString();
mySysLogRow["Username"] =
myuser.Username.ToString();
mySysLogRow["Message"] =
"Created in DG QuoteID " +
dgdet[x]["QuoteID"];

objDataSet.SystemLog.Rows.Add(mySysLogRow);
}
test =
SysTableAdapter.Update(objDataSet, "SystemLog");
Console.WriteLine("saved " +
test.ToString() + " log rows");

notedet =
objDataSet.Notes.Select("","",DataViewRowState.Add ed);
Console.WriteLine("found " +
notedet.Length + " rows");
numOfRows =
NoteTableAdapter.Update(notedet);
Console.WriteLine("saved " +
numOfRows.ToString() + " rows");
for (int x = 0; x < notedet.Length; x++)
{
DataRow mySysLogRow =
objDataSet.SystemLog.NewRow();
mySysLogRow["DayTime"] =
System.DateTime.Now.ToString();
mySysLogRow["Username"] =
myuser.Username.ToString();
mySysLogRow["Message"] =
"Created in Notes QuoteID " +
notedet[x]["QuoteID"];

objDataSet.SystemLog.Rows.Add(mySysLogRow);
}
test =
SysTableAdapter.Update(objDataSet, "SystemLog");
Console.WriteLine("saved " +
test.ToString() + " log rows");

proddet =
objDataSet.ProductsUsedInQuotes.Select("","",DataV iewRowState.Added);
Console.WriteLine("found " +
proddet.Length + " rows");
numOfRows =
ProdUsedTableAdapter.Update(proddet);
Console.WriteLine("saved " +
numOfRows.ToString() + " rows");
for (int x = 0; x < proddet.Length; x++)
{
DataRow mySysLogRow =
objDataSet.SystemLog.NewRow();
mySysLogRow["DayTime"] =
System.DateTime.Now.ToString();
mySysLogRow["Username"] =
myuser.Username.ToString();
mySysLogRow["Message"] =
"Created in ProductsUsedInQuotes QuoteID
" + proddet[x]["QuoteID"];

objDataSet.SystemLog.Rows.Add(mySysLogRow);
}
test =
SysTableAdapter.Update(objDataSet, "SystemLog");
Console.WriteLine("saved " +
test.ToString() + " log rows");

//store modified changes
shipdet =
objDataSet.Quotes.Select("","",DataViewRowState.Mo difiedCurrent);
Console.WriteLine("found " +
shipdet.Length + " rows");
numOfRows =
HAWBTableAdapter.Update(shipdet);
Console.WriteLine("saved " +
numOfRows.ToString() + " rows");
for (int x = 0; x < shipdet.Length; x++)
{
DataRow mySysLogRow =
objDataSet.SystemLog.NewRow();
mySysLogRow["DayTime"] =
System.DateTime.Now.ToString();
mySysLogRow["Username"] =
myuser.Username.ToString();
mySysLogRow["Message"] =
"Modified in Quotes QuoteID " +
shipdet[x]["QuoteID"];

objDataSet.SystemLog.Rows.Add(mySysLogRow);
}
test =
SysTableAdapter.Update(objDataSet, "SystemLog");
Console.WriteLine("saved " +
test.ToString() + " log rows");

shipprofdet =
objDataSet.ShipmentProfile.Select("","",DataViewRo wState.ModifiedCurrent);
Console.WriteLine("found " +
shipprofdet.Length + " rows");

numOfRows =
DimTableAdapter.Update(shipprofdet);
Console.WriteLine("saved " +
numOfRows.ToString() + " rows");
for (int x = 0; x < shipprofdet.Length;
x++)
{
DataRow mySysLogRow =
objDataSet.SystemLog.NewRow();
mySysLogRow["DayTime"] =
System.DateTime.Now.ToString();
mySysLogRow["Username"] =
myuser.Username.ToString();
mySysLogRow["Message"] =
"Modified in Shipment Profile QuoteID " +
shipprofdet[x]["QuoteID"];

objDataSet.SystemLog.Rows.Add(mySysLogRow);
}
test =
SysTableAdapter.Update(objDataSet, "SystemLog");
Console.WriteLine("saved " +
test.ToString() + " log rows");

dgdet =
objDataSet.DG.Select("","",DataViewRowState.Modifi edCurrent);
Console.WriteLine("found " +
dgdet.Length + " rows");
numOfRows =
DGTableAdapter.Update(dgdet);
Console.WriteLine("saved " +
numOfRows.ToString() + " rows");
for (int x = 0; x < dgdet.Length; x++)
{
DataRow mySysLogRow =
objDataSet.SystemLog.NewRow();
mySysLogRow["DayTime"] =
System.DateTime.Now.ToString();
mySysLogRow["Username"] =
myuser.Username.ToString();
mySysLogRow["Message"] =
"Modified in DG QuoteID " +
dgdet[x]["QuoteID"];

objDataSet.SystemLog.Rows.Add(mySysLogRow);
}
test =
SysTableAdapter.Update(objDataSet, "SystemLog");
Console.WriteLine("saved " +
test.ToString() + " log rows");

notedet =
objDataSet.Notes.Select("","",DataViewRowState.Mod ifiedCurrent);
Console.WriteLine("found " +
notedet.Length + " rows");
numOfRows =
NoteTableAdapter.Update(notedet);
Console.WriteLine("saved " +
numOfRows.ToString() + " rows");
for (int x = 0; x < notedet.Length; x++)
{
DataRow mySysLogRow =
objDataSet.SystemLog.NewRow();
mySysLogRow["DayTime"] =
System.DateTime.Now.ToString();
mySysLogRow["Username"] =
myuser.Username.ToString();
mySysLogRow["Message"] =
"Modified in Notes QuoteID " +
notedet[x]["QuoteID"];

objDataSet.SystemLog.Rows.Add(mySysLogRow);
}
test =
SysTableAdapter.Update(objDataSet, "SystemLog");
Console.WriteLine("saved " +
test.ToString() + " log rows");

proddet =
objDataSet.ProductsUsedInQuotes.Select("","",DataV iewRowState.Added);
Console.WriteLine("found " +
proddet.Length + " rows");
numOfRows =
ProdUsedTableAdapter.Update(proddet);
Console.WriteLine("saved " +
numOfRows.ToString() + " rows");
for (int x = 0; x < proddet.Length; x++)
{
DataRow mySysLogRow =
objDataSet.SystemLog.NewRow();
mySysLogRow["DayTime"] =
System.DateTime.Now.ToString();
mySysLogRow["Username"] =
myuser.Username.ToString();
mySysLogRow["Message"] =
"Modified in ProductsUsedInQuotes QuoteID
" + proddet[x]["QuoteID"];

objDataSet.SystemLog.Rows.Add(mySysLogRow);
}
test =
SysTableAdapter.Update(objDataSet, "SystemLog");
Console.WriteLine("saved " +
test.ToString() + " log rows");

//store deletes
shipprofdet =
objDataSet.ShipmentProfile.Select("","",DataViewRo wState.Deleted);
Console.WriteLine("found " +
shipprofdet.Length + " rows");
numOfRows =
DimTableAdapter.Update(shipprofdet);
Console.WriteLine("saved " +
numOfRows.ToString() + " rows");
for (int x = 0; x < shipprofdet.Length;
x++)
{
DataRow mySysLogRow =
objDataSet.SystemLog.NewRow();
mySysLogRow["DayTime"] =
System.DateTime.Now.ToString();
mySysLogRow["Username"] =
myuser.Username.ToString();
mySysLogRow["Message"] =
"Deleted in Shipment Profile QuoteID " +
shipprofdet[x]["QuoteID"];

objDataSet.SystemLog.Rows.Add(mySysLogRow);
}
test =
SysTableAdapter.Update(objDataSet, "SystemLog");
Console.WriteLine("saved " +
test.ToString() + " log rows");

dgdet =
objDataSet.DG.Select("","",DataViewRowState.Delete d);
Console.WriteLine("found " +
dgdet.Length + " rows");
numOfRows =
DGTableAdapter.Update(dgdet);
Console.WriteLine("saved " +
numOfRows.ToString() + " rows");
for (int x = 0; x < dgdet.Length; x++)
{
DataRow mySysLogRow =
objDataSet.SystemLog.NewRow();
mySysLogRow["DayTime"] =
System.DateTime.Now.ToString();
mySysLogRow["Username"] =
myuser.Username.ToString();
mySysLogRow["Message"] =
"Deleted in DG QuoteID " +
dgdet[x]["QuoteID"];

objDataSet.SystemLog.Rows.Add(mySysLogRow);
}
test =
SysTableAdapter.Update(objDataSet, "SystemLog");
Console.WriteLine("saved " +
test.ToString() + " log rows");

notedet =
objDataSet.Notes.Select("","",DataViewRowState.Del eted);
Console.WriteLine("found " +
notedet.Length + " rows");
numOfRows =
NoteTableAdapter.Update(notedet);
Console.WriteLine("saved " +
numOfRows.ToString() + " rows");
for (int x = 0; x < notedet.Length; x++)
{
DataRow mySysLogRow =
objDataSet.SystemLog.NewRow();
mySysLogRow["DayTime"] =
System.DateTime.Now.ToString();
mySysLogRow["Username"] =
myuser.Username.ToString();
mySysLogRow["Message"] =
"Deleted in Notes QuoteID " +
notedet[x]["QuoteID"];

objDataSet.SystemLog.Rows.Add(mySysLogRow);
}
test =
SysTableAdapter.Update(objDataSet, "SystemLog");
Console.WriteLine("saved " +
test.ToString() + " log rows");

proddet =
objDataSet.ProductsUsedInQuotes.Select("","",DataV iewRowState.Deleted);
Console.WriteLine("found " +
proddet.Length + " rows");
numOfRows =
ProdUsedTableAdapter.Update(proddet);
Console.WriteLine("saved " +
numOfRows.ToString() + " rows");
for (int x = 0; x < proddet.Length; x++)
{
DataRow mySysLogRow =
objDataSet.SystemLog.NewRow();
mySysLogRow["DayTime"] =
System.DateTime.Now.ToString();
mySysLogRow["Username"] =
myuser.Username.ToString();
mySysLogRow["Message"] =
"Deleted in ProductsUsedInQuotes QuoteID
" + proddet[x]["QuoteID"];

objDataSet.SystemLog.Rows.Add(mySysLogRow);
}
test =
SysTableAdapter.Update(objDataSet, "SystemLog");
Console.WriteLine("saved " +
test.ToString() + " log rows");

shipdet =
objDataSet.Quotes.Select("","",DataViewRowState.De leted);
Console.WriteLine("found " +
shipdet.Length + " rows");
numOfRows =
HAWBTableAdapter.Update(shipdet);
Console.WriteLine("saved " +
numOfRows.ToString() + " rows");
for (int x = 0; x < shipdet.Length; x++)
{
DataRow mySysLogRow =
objDataSet.SystemLog.NewRow();
mySysLogRow["DayTime"] =
System.DateTime.Now.ToString();
mySysLogRow["Username"] =
myuser.Username.ToString();
mySysLogRow["Message"] =
"Deleted in Quotes QuoteID " +
shipdet[x]["QuoteID"];

objDataSet.SystemLog.Rows.Add(mySysLogRow);
}
test =
SysTableAdapter.Update(objDataSet, "SystemLog");
Console.WriteLine("saved " +
test.ToString() + " log rows");
*/
}
catch (SqlException ex)
{
for (int i = 0; i < ex.Errors.Count;
i++)
{
errorMessages.Append("Index #" +
i + "\n" +
"Message: " +
ex.Errors[i].Message + "\n" +
"LineNumber: " +
ex.Errors[i].LineNumber + "\n" +
"Source: " +
ex.Errors[i].Source + "\n" +
"Procedure: " +
ex.Errors[i].Procedure + "\n");
}

Console.WriteLine(errorMessages.ToString());
MessageBox.Show("An Error Occured.
Please check your page and try
again.");
}

cl.Close();
}

Oct 20 '06 #1
0 1710

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Hennie de Nooijer | last post by:
Hi, Currently we're a building a metadatadriven datawarehouse in SQL Server 2000. We're investigating the possibility of the updating tables with enormeous number of updates and insert and the...
3
by: Robin Tucker | last post by:
Hi there, I have a database on my test machine that will need to be installed on users machines. I would like to create the database with the given schema on the users machine and also with...
4
by: vbportal | last post by:
Hi, Not sure if this is the right group for the question: I've just finished a course/certification where I've used Visual Studio and want to work further on software development with C#,ADO,ASP...
3
by: Ryan.Chowdhury | last post by:
This is a general question regarding the use of view and stored procedures. I'm fairly new to databases and SQL. I've created a SQL database using an Access Data Project ("ADP") and I'm...
2
by: Gene Vital | last post by:
Hi all. I am using Visual FoxPro via ODBC to update records on a 7.3.4 PostgreSql server and it appears that it always uses delete/insert instead of updating the current record. Can this be...
34
by: Jeff | last post by:
For years I have been using VBA extensively for updating data to tables after processing. By this I mean if I had to do some intensive processing that resulted in data in temp tables, I would have...
7
by: Greg P | last post by:
I'm new to VS2005 and want to simply update my data with the dataGridView that was generated when I draged my query from the Data Sources Pane. I think I may need to create a Data Adaptor but I'm...
1
by: JT | last post by:
In Visual Studio 2005, I used the Data - Add New Data Source wizard to create a new Table Adapter data set to interface to my SQL Server 2005 database. Then I wrote this C# code to add new...
15
by: slinky | last post by:
Thanks in advance fo rany help... I have an XML data file (well- formed) that I need to place into my website's app_data folder. I would like to have an .aspx form on my site that simply has two...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.