473,563 Members | 2,831 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DataSet Always Returning True

2 New Member
Hi guys, I'm really hoping that someone can help me...

I have 3 datasets. One that will contain the initial information when I open up the database; one that will pull in information afterwards; and a 3rd to show the changes that have occured since merging #1 and #2.

Now when I'm testing this data, it seems that HasChanges always returns true.

Am I invoking something wrong? Am I not using AcceptChanges and HasChanges properly??

Here is what I have


[code]
using System;
using System.Data;
using System.Collecti ons.Generic;
using System.IO;
using System.Linq;
using System.Xml;
using System.Xml.Seri alization;
using System.Text;
using MySql.Data;
using MySql.Data.MySq lClient;


namespace MySQL
{
class Program
{
static void Main(string[] args)
{
//***Load the Configuration Data***//

Configuration myConfig = new Configuration() ;
myConfig.Config urationLoader() ;

String MyConnString =
myConfig.connec tion_info.datab ase[1].connection_str ing;

//-----Define the MySQL Connection

MySqlConnection connection = new MySqlConnection (MyConnString);

//---Take the inital snap shot

Snapshot snapshot = new Snapshot();
snapshot.intial _snap_shot(myCo nfig, connection);

//--Enter the loop checking for new data--//

while (true)
{
Console.WriteLi ne("Press enter to start looking for new data");
Console.ReadLin e();

snapshot.merge_ snap_shot(myCon fig, connection);

//Merge Data

snapshot.Merge( );
}
}
}
}



using System;
using System.Data;
using System.Collecti ons.Generic;
using System.IO;
using System.Linq;
using System.Xml;
using System.Xml.Seri alization;
using System.Text;
using MySql.Data;
using MySql.Data.MySq lClient;

namespace MySQL
{
class Snapshot
{
private DataSet primary_ds = new DataSet();
private DataSet merge_ds = new DataSet();
private DataSet diff_ds = new DataSet();

public void intial_snap_sho t(Configuration myConfig , MySqlConnection conn)
{
for (int i = 0; i < myConfig.config uration.schedul ing.OutgoingDat a.Tables1.Lengt h; i++)
{
Console.WriteLi ne("Table Count : " + primary_ds.Tabl es.Count.ToStri ng());
MySqlDataSet(my Config.configur ation.schedulin g.OutgoingData. Tables1[i].name, conn);

Console.WriteLi ne("Row Count For Table : " + i.ToString() + " : "
+ primary_ds.Tabl es[i].Rows.Count.ToS tring());


}


}

public void merge_snap_shot (Configuration myConfig, MySqlConnection conn)
{
for (int i = 0; i < myConfig.config uration.schedul ing.OutgoingDat a.Tables1.Lengt h; i++)
{
Console.WriteLi ne("Table Count : " + merge_ds.Tables .Count.ToString ());
MySqlDataSet2(m yConfig.configu ration.scheduli ng.OutgoingData .Tables1[i].name, conn);

Console.WriteLi ne("Row Count For Table : " + i.ToString() + " : "
+ merge_ds.Tables[i].Rows.Count.ToS tring());
}
}


public void MySqlDataSet(St ring TableName, MySqlConnection conn)
{
MySqlDataAdapte r adapter = new MySqlDataAdapte r("SELECT * FROM " + TableName, conn);

adapter.Missing SchemaAction = MissingSchemaAc tion.AddWithKey ;
adapter.Fill(pr imary_ds);
primary_ds.Tabl es[primary_ds.Tabl es.Count - 1].TableName = TableName;
primary_ds.Tabl es[primary_ds.Tabl es.Count - 1].AcceptChanges( );

}

public void MySqlDataSet2(S tring TableName, MySqlConnection conn)
{
MySqlDataAdapte r adapter = new MySqlDataAdapte r("SELECT * FROM " + TableName, conn);
adapter.Missing SchemaAction = MissingSchemaAc tion.AddWithKey ;
adapter.Fill(me rge_ds);
merge_ds.Tables[merge_ds.Tables .Count - 1].TableName = TableName;
}

public void Merge()
{
primary_ds.Merg e(merge_ds, true);

if (primary_ds.Has Changes())
{
Console.WriteLi ne("Changes Exist");
primary_ds.Acce ptChanges();
merge_ds.Accept Changes();
}
else
{
Console.WriteLi ne("No Changes");
}
}


}
}
Jul 26 '07 #1
0 1285

Sign in to post your reply or Sign up for a free account.

Similar topics

0
1770
by: Brendan Reynolds | last post by:
I have a web service that takes the XML representation of a dataset and uses XSLT to transform it to the format required to open a disconnected ADODB recordset on the XML, and returns the transformed XML as a string, for use in an Access/VBA application. The transformed XML looks, in part, like this .... <z:row...
9
1363
by: Jarod | last post by:
Hey Will be in .net 2.0 any nice way to use stored procedures and get typed dataset ? Jarod
1
1590
by: Azkaban | last post by:
Hi I succeded to add a DataColumn to DataSet but now I've one big problem. The value of this column would be a personal function result, I try a lot of time but the result is always empty. Why? There's a method to do this thing? This is the code cols = ImageDataSet.Tables("Immagini").Columns myCol = cols.Add() With myCol
1
1912
by: Dave | last post by:
I am relativly new to visual basic, so this may be a no- brainer. I am attempting to use a computed column in a VB dataset defined as followe: ' 'dcCost ' Me.dcCost.ColumnName = "Cost"
1
3729
by: JoshKaos | last post by:
I am in the process of rewriting a WebService. The WebMethods are all returning XMLDocuments. First, they get a Dataset of records and then walk through the Dataset to populate the XMLDocument which is then passed to the Web application which then pushes the XMLDocument into a Dataset in order to use the data. Now my question is should I...
1
5536
by: J. Askey | last post by:
I am implementing a web service and thought it may be a good idea to return a more complex class (which I have called 'ServiceResponse') in order to wrap the original return value along with two other properties... bool error; string lastError; My whole class looks like this... using System;
1
3270
by: Meelis Lilbok | last post by:
Hi Still cant resolve problem, how to get datatype and properties for field. If if fill DataSet from SQL Database how can i a) Get DataType for specified field b) Get Allow null (if i read AllowDBNull this returns always True)
13
2332
by: Maxwell2006 | last post by:
Hi, We are having a debate over using DataSet as return value type for web services. The problem is that we don't know whether Java applications can use DataSet
15
13490
by: Joseph Geretz | last post by:
I'm a bit puzzled by the current recommendation not to send Datasets or Datatables between application tiers. http://support.microsoft.com/kb/306134 http://msdn2.microsoft.com/en-us/library/ms996381.aspx Formerly, with classic Microsoft DNA architecture, the ADO Recordset was a primary transport medium, recommended for transmitting data...
0
7664
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7583
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7885
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8106
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
6250
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5484
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1198
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
923
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.