PC Review


Reply
Thread Tools Rate Thread

Converting Database Schema

 
 
Islamegy
Guest
Posts: n/a
 
      17th Sep 2005
In my C# project..
I have Sql Database with data of 700 MB... I'm redesign tables and
relations and need to retrieve my data in the new tables..

I'm using SqlAdapter to Get old tables in my dataset then use the
GetChildRows()... insert new records in the new tables.
Here is the code which convert first 2 tables to 3 new tables:-

####### CODE START #######################
private void btn_Start_Click(object sender, System.EventArgs e)

{

this.transActionStart();

}

private void transActionStart()

{

progressBar1.Value = 0;

adp_Old_E7sea2ya.Fill(dsOld.E7saeya_List);

adp_Old_Country_list.Fill(dsOld.E7saeya_Country_List);

adp_Old_Mo2shrat.Fill(dsOld.E7saeyaDetails);

adp_Old_Mo2_Details.Fill(dsOld.E7saeya_Main);

progressBar1.Maximum = dsOld.E7saeya_List.Rows.Count;

this.setAhsa2yat();

}

private void setAhsa2yat()

{

ni_Ahsa2yat = new NewIndex();

foreach (DataSetOld.E7saeya_ListRow row in dsOld.E7saeya_List)

{

int ah_id = ni_Ahsa2yat.GetIndex("Ahsa2yat");

int succ = this.sqlCommandParam(Ins_Ahsa2ya, ah_id, row.E7saeya_Name);

if (succ == 1)

{

ni_Ahsa2yat.UpdateIndex("Ahsa2yat");

DataSetOld.E7saeya_Country_ListRow[] rows=
(DataSetOld.E7saeya_Country_ListRow[])row.GetChildRows("Rel_AH_Country");

this.setCountries(rows, row.E7saeya_ID, ah_id);

}


System.Threading.Thread.Sleep(1);

progressBar1.Value += 1;

}

Conn.Close();

}


private void setCountries(DataSetOld.E7saeya_Country_ListRow[]
e7saeya_Country_ListRows, int old_E7sa2ya_ID, int new_A7sa2ya_ID)

{

ni_Country = new NewIndex();

foreach (DataSetOld.E7saeya_Country_ListRow row in e7saeya_Country_ListRows)

{

DataSetOld.E7saeyaDetailsRow[] rows =
(DataSetOld.E7saeyaDetailsRow[])row.GetChildRows("Rel_Country_Mo2");


int country_id = ni_Ahsa2yat.GetIndex("Country");

int sucess =
this.sqlCommandParam(Ins_Country,country_id,row.E7saeya_Country_Name);

if(sucess == 1)

{

ni_Country.UpdateIndex("Country");

this.setAHCountry(rows, row.E7saeya_Country_ID, new_A7sa2ya_ID, country_id);

}

else

{

SelCountryID.Parameters["@NAME"].Value = row.E7saeya_Country_Name;

int exist_id = (int)SelCountryID.ExecuteScalar();

this.setAHCountry(rows, row.E7saeya_Country_ID, new_A7sa2ya_ID, exist_id);

}

}

}


private void setAHCountry(DataSetOld.E7saeyaDetailsRow[] e7saeyaDetailsRows,
int old_AH_Country_ID, int new_A7sa2ya_ID, int new_country_id)

{

ni_Ah_Country = new NewIndex();

int ah_country_id = ni_Ah_Country.GetIndex("Ahsa2_Country");

int success =
this.sqlCommandParam(Ins_AhCountry,ah_country_id,new_A7sa2ya_ID,new_country_
id);

if(success == 1)

{

ni_Ah_Country.UpdateIndex("Ahsa2_Country");

setMo2shrat(e7saeyaDetailsRows, old_AH_Country_ID, ah_country_id);

}

}

################ CODE END ####################



My Company was using Delphi and I'm megrate everything to C#.. My way work
well but take to much time and memory, The old Delphi Code was doing this
task in 20% of the time and don't use so much system resources like mine?!

Is there better way to copy my data with the new shcema??

thanx


 
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
Database Schema help Jason G Microsoft Access Database Table Design 2 23rd Nov 2009 12:12 PM
using XSD Database Schema for database creation and update WM Developer Microsoft Dot NET Compact Framework 0 20th Sep 2008 12:18 AM
Database Schema jack Microsoft C# .NET 3 15th Feb 2008 10:06 PM
Can I sync a typed dataset schema with database schema easily? John Microsoft Dot NET 1 2nd Jan 2008 10:37 AM
Converting Access data to XML using provided XML schema Pow Microsoft Access 0 5th May 2005 05:57 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:33 AM.