Click here to Skip to main content
15,924,367 members
Home / Discussions / Database
   

Database

 
GeneralRe: Different Table Column in a DataGrid Pin
Tomy140218-Dec-06 15:17
Tomy140218-Dec-06 15:17 
GeneralRe: Different Table Column in a DataGrid Pin
Kschuler19-Dec-06 3:01
Kschuler19-Dec-06 3:01 
GeneralRe: Different Table Column in a DataGrid Pin
Tomy140219-Dec-06 21:29
Tomy140219-Dec-06 21:29 
GeneralRe: Different Table Column in a DataGrid Pin
Tomy140219-Dec-06 21:39
Tomy140219-Dec-06 21:39 
GeneralRe: Different Table Column in a DataGrid Pin
Kschuler20-Dec-06 2:46
Kschuler20-Dec-06 2:46 
GeneralRe: Different Table Column in a DataGrid [modified] Pin
Tomy140220-Dec-06 15:34
Tomy140220-Dec-06 15:34 
GeneralRe: Different Table Column in a DataGrid Pin
Kschuler21-Dec-06 2:48
Kschuler21-Dec-06 2:48 
GeneralRe: Different Table Column in a DataGrid Pin
Tomy140221-Dec-06 15:39
Tomy140221-Dec-06 15:39 
Clearing DataTable really works. But, what if there are thousands rows?

Anywayay, here's the code:
I have a Static Class which holds the only DataSet in my program. All DataTables created are stored in that DataSet.

/*******************************************************************/
public static DataSet dsObj = new DataSet(); //the one and only DataSet in my program
public static MySqlConnection connObj = new MySqlConnection(connStr);

//method to add Table or Tables to DataSet
public static void addTblsToDsObj(String tblName)
{
String[] tblArr = tblName.Split(',');

dsObj.EnforceConstraints = false; //I remove constrain before clearing DataTable, because of ForeignKey problem

for (int i = 0; i < tblArr.Length; i++ )
{
if(dsObj.Tables.Contains(tblArr[i])){ //If DataSet has same Table, I clear that table before fill it again

dsObj.Tables[tblArr[i]].Clear();
}
}

dsObj.EnforceConstraints = true; //after needed tables are cleared, I set it to true because I want to load the primary key too.

for (int i = 0; i < tblArr.Length; i++)
{
MySqlDataAdapter daObj = new MySqlDataAdapter("SELECT * FROM " + tblArr[i], connObj);
MySqlCommandBuilder cbObj = new MySqlCommandBuilder(daObj);
daObj.MissingSchemaAction = MissingSchemaAction.AddWithKey;
daObj.Fill(dsObj, tblArr[i]);
}
}
/*******************************************************************/

Now, everytime my Form load a Table from MySQL, I call method addTblsToDsObj(String tblName).

Note that code above works fine with deleted data outside my Program environtment (because if Clear method).

I repeat my question above, what if I have thousand of rows? it means I will clear a lot of unnecessary rows right? so I guess it's not an optimal performance.

Thx for any help. I'll try to post this as new message too.
Questionhow to get a specific no of rows in sql Pin
Rocky#17-Dec-06 7:45
Rocky#17-Dec-06 7:45 
AnswerRe: how to get a specific no of rows in sql Pin
Pete O'Hanlon17-Dec-06 8:44
mvePete O'Hanlon17-Dec-06 8:44 
GeneralRe: how to get a specific no of rows in sql Pin
Rocky#19-Dec-06 0:35
Rocky#19-Dec-06 0:35 
QuestionSQL Reporting Services Pin
Jimbo2517-Dec-06 6:23
Jimbo2517-Dec-06 6:23 
Questionhow to import tables Pin
Marc Soleda17-Dec-06 1:42
Marc Soleda17-Dec-06 1:42 
AnswerRe: how to import tables Pin
Colin Angus Mackay17-Dec-06 8:29
Colin Angus Mackay17-Dec-06 8:29 
QuestionReporting Services Pin
Sergio Luix16-Dec-06 8:36
Sergio Luix16-Dec-06 8:36 
QuestionASP.NET + OPEN DATABASE (HSQL) Pin
Vitor Hugo Barros16-Dec-06 1:29
Vitor Hugo Barros16-Dec-06 1:29 
QuestionUse stored procedure to check if database exist Pin
kani9815-Dec-06 12:19
kani9815-Dec-06 12:19 
AnswerRe: Use stored procedure to check if database exist Pin
Private_Void15-Dec-06 14:53
Private_Void15-Dec-06 14:53 
GeneralRe: Use stored procedure to check if database exist Pin
kani9818-Dec-06 12:30
kani9818-Dec-06 12:30 
GeneralRe: Use stored procedure to check if database exist Pin
Private_Void19-Dec-06 3:08
Private_Void19-Dec-06 3:08 
QuestionHelp with date math. Pin
Chris Meech15-Dec-06 8:24
Chris Meech15-Dec-06 8:24 
AnswerRe: Help with date math. Pin
Chris Meech15-Dec-06 9:17
Chris Meech15-Dec-06 9:17 
Questionmultiple rows output to one rows Pin
nmandaliya15-Dec-06 7:41
nmandaliya15-Dec-06 7:41 
Questiongetting "unsupported data" in the column when selected Price from table field Pin
yogita charhate15-Dec-06 4:33
yogita charhate15-Dec-06 4:33 
AnswerRe: getting &quot;unsupported data&quot; in the column when selected Price from table field Pin
Frank Kerrigan15-Dec-06 5:21
Frank Kerrigan15-Dec-06 5:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.