Advanced reporting
and data visualization components for .NET
LIVE CHAT Welcome, guest

 





Reading Database with Database.Read() fails
Display Posts for:
Invert
Robert Rupf 06/18/2010 11:46
Reading Database with Database.Read() fails

Hello again! =)

After avoiding all so far encountered problems I think I found another Bug.

When creating an internal representation of a database directly from the MSSQL-Server everything seems to be fine:
Code:
// Delphi-Code
m_sourceDB := m_sync.ReverseDatabase(conn_str.ConnectionString);

I even can write this database into a XML-file:
Code:
m_sourceDB.Write('source.xml');

But when I try to read a XML-file, which contains a database, and then want to write this database again into a file, I get a empty database:
Code:
m_sourceDB.Read('source.xml', SerializationMode.UncompressedXml);
m_sourceDB.Write('source_out.xml');

"source_out.xml" now looks like this:
Code:
<root type="PerpetuumSoft.DataModel.MsSql.Database" id="1" version="2" SqlVersion="Sql2005">
<Options type="PerpetuumSoft.DataModel.MsSql.DatabaseOptions" id="2" Trustworthy="false" DefaultCursor="Global" ConcatenateNullYieldsNull="false" AnsiNullDefault="false" CloseCursorsOnCommitEnables="false" AnsiNullsEnabled="false" AutoCreateStatistic="true" AutoUpdateStatistic="true" ArithmeticAbortEnabled="false" AnsiWarningsEnabled="false" AutoUpdateStatisticAsync="false" DatabaseOwnershipChaining="false" Parametrization="Simple" AutoShrink="false" AnsiPaddingEnabled="false" AutoClose="false" PageVerify="Checksum" QuotedIdentifiersEnabled="false" RecursiveTriggersEnabled="false" NumericRoundAbortEnabled="false"/>
<ExtendedProperties type="PerpetuumSoft.DataModel.MsSql.ExtendedPropertyCollection" id="3"/>
<Objects type="PerpetuumSoft.DataModel.MsSql.DatabaseObjectCollection" id="4"/>
</root>


Can you show me, where I am mistaken?
And if I am not, can you resolve the problem?

Kind regards,
Xong
Vlad Nekrasov 06/21/2010 06:30
Reading Database with Database.Read() fails

Hello,
Judging by the file the
m_sourceDB := m_sync.ReverseDatabase(conn_str.ConnectionString);
method creates, but doesn’t fill the PerpetuumSoft.DataModel.MsSql.DatabaseObjectCollection collection.

In order to make sure in this you should check after this operation the availability of some data base object which name you know. For example, of a table:
m_sourceDB.Objects[“nameOfMyTable”] != null;


Best regards,
Vlad Nekrasov
Perpetuum Software Team
Robert Rupf 06/21/2010 07:05
Reading Database with Database.Read() fails

Good Morning to you from Germany!

Thank you for your answer.

My problem is not connected with the ReverseDatabase()-method but with the Database.Read()-method.

Filling a Database-object with the ReverseDatabase-method perfectly performs the task.

But when I read a compressed or uncompressed XML-file which contains a database description, the DatabaseObjectCollection has no objects.

This is my approach:
1. I create a snapshot of the AdventureWorks-database with SQL Schema Sync Wizard or I create the snapshot by myself with the Database.Write()-method.
2. I use following Code to load the database stored in the snapshot:
Code:
m_sourceDB := new Database();
m_sourceDB.Read('AdventureWorks.dbsnapshot', SerializationMode.CompressedXml);

System.Windows.Forms.MessageBox.Show(m_sourceDB.Objects.Count.ToString);
3. The message in the messagebox shows only a "0".

I am a little bit startled why the Read()-method seems not to import the database correctly.

If I use the ReverseDatabase()-method on the AdventureWorks-table instead the messagebox outputs the correct number of objects: 679.

Parsing the XML-file manually is possible but would mean a much greater effort than I invested so far.

You can download the used snapshot here: http://maumha.de/AdventureWorks.dbsnapshot

Kind regards,
Robert Rupf
Robert Rupf 06/21/2010 09:21
Reading Database with Database.Read() fails

Hi!

I am a little bit more confused now.

The problem still exists. But when using SQL Schema Sync Wizard it is possible to choose a dbsnapshot-file and the programm generates the SQL-scripts just fine.

What is your code doing different from mine?

I would be more than happy, if you could give me a glimpse at the couple of lines, which import a file in the SQL Schema Sync Wizard.

Thank you,
Robert Rupf
Robert Rupf 06/22/2010 05:17
Reading Database with Database.Read() fails

Hello again!

I found a Workaround for my problem.

While Database.Read() fails following Code works fine for uncompressed database snapshots:
Code:
m_source := new Database();
xmlreader := new XmlTextReader(_filename);
serialmanager := new XSerializationManager();

//m_source.Read(_filename, _mode); // does not work
m_source := (new XSerializationManager().Deserialize(xmlreader)) as Database;

I am very happy with this solution because it saves me a lot of additional, unnecessary trouble.

Kind regards,
Robert
Vlad Nekrasov 06/22/2010 07:13
Reading Database with Database.Read() fails

Hello,

Here is the code which reads the xml (.dbsnapshot) file in our Wizard:

Code:
MsSql.Database db;
try
{
db = MsSql.Database.Read(loadSnapshotControl.SnapshotFileName, Serialization.SerializationMode.CompressedXml);
}
catch
{
try
{
db = MsSql.Database.Read(loadSnapshotControl.SnapshotFileName);
}
catch
{
throw new Exception("Can't load database from snapshot. Please, make sure file format is correct."));
}


The record to the file looks the same.


Best regards,
Vlad Nekrasov
Perpetuum Software Team