Click to See Complete Forum and Search --> : store arraylist in database


jagmit
October 9th, 2009, 03:57 PM
I have an arraylist which has a list of structures stored in it
Now i need to store these structures in a database, where each structure has its own line.

public struct BackupSpecEntry
{
//for Multiple BACKUP_SPEC_EXCLUDE_PATHS
public string path;
public string inclExcl;
public byte inclExclFlags;
public bool indexContents;
public int serverBackupSpecId;
public int freq;
public int retention;

//for Multiple BACKUP_SPEC_EXCLUDE_FILE_NAMES

public BackupSpecEntry(string Path, string InclExcl, byte InclExclFlags, bool IndexContents,
int ServerBackupSpecId, int Freq, int Retention)
{
path = Path;
inclExcl = InclExcl;
inclExclFlags = InclExclFlags;
indexContents = IndexContents;
serverBackupSpecId = ServerBackupSpecId;
freq = Freq;
retention = Retention;
}
}


My arraylist is ArrayList backupSpecList = new ArrayList();


how to store this in a database....

Arjay
October 9th, 2009, 06:05 PM
What database are you using? MS SQL? MySQL, Access? Are you using stored procedures?

Phelim
October 11th, 2009, 05:33 AM
It's depends what you are looking for.
You can store serialize object in your database. To make that, you can use Xmlserialize class

Advantage :
- Whatever the structures, the object can be store in the db

Disadvantage :
- You don't have any controle about the data integrity in the database
- When your code change it'll require to make a script to change the format of data already stored (maintenance is heavy)
- You can't use the SQL easily to make some search in the db

This solution is very simple but I don't advise if your application'll change frequently or if your data'll be used by other softwares.