Click here to Skip to main content
15,884,425 members
Home / Discussions / C#
   

C#

 
QuestionGetting this Error message....any one know y??? Pin
S K Y11-Mar-09 14:47
S K Y11-Mar-09 14:47 
AnswerRe: Getting this Error message....any one know y??? Pin
DaveyM6911-Mar-09 14:56
professionalDaveyM6911-Mar-09 14:56 
GeneralRe: Getting this Error message....any one know y??? Pin
S K Y11-Mar-09 15:26
S K Y11-Mar-09 15:26 
GeneralRe: Getting this Error message....any one know y??? Pin
DaveyM6911-Mar-09 15:34
professionalDaveyM6911-Mar-09 15:34 
GeneralRe: Getting this Error message....any one know y??? Pin
Christian Graus11-Mar-09 15:58
protectorChristian Graus11-Mar-09 15:58 
GeneralRe: Getting this Error message....any one know y??? Pin
S K Y11-Mar-09 18:18
S K Y11-Mar-09 18:18 
QuestionHow to use OleDbConnection or SqlCommand to read Schema and database records [modified] Pin
granthamlee11-Mar-09 14:30
granthamlee11-Mar-09 14:30 
QuestionSyste.OutOfMemoryException Pin
Member 461797111-Mar-09 14:23
Member 461797111-Mar-09 14:23 
I have a little problem I need some help with. IM a novice C# programmer.

Im working on a piece of software that scans a directory for mp3 files loading the filepaths into an array. It then reads some info from the ID3 tags and attempts to write this info to an Access database. All seems to work fine except after about 25 files I get a System.OutOfMemory Exception. Im thinking either the ID3Info objects or the OleDbCommand objects arent disposing correctly so I threw in the System.GC.Collect and it did succeed in getting me farther but Im still getting the error. Anyone see anything Im missing?

int i = 0,duration, year;
     string artist, title, album, bandname, genre, path;
     string delSql = "DELETE * FROM Library";
     musLibConn.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Program Files\GeneSys\Library.mdb";
     OleDbCommand deleteLib = new OleDbCommand(delSql, musLibConn);
     musLibConn.Open();
     if (tbMusPath.Text != "")
     {
         utility util = new utility();
         filepaths = Directory.GetFiles(util.getLibPath(), "*.mp3", SearchOption.AllDirectories);
         deleteLib.ExecuteNonQuery();
         ID3Info CurrSong;
         OleDbCommand insertLib;
         pBar.Visible = true;

         foreach(string str in filepaths)
         {
             //pBar.Value = i % 100;
             CurrSong = new ID3Info(filepaths[i], true);
             path = filepaths[i].ToString();
             artist = CurrSong.ID3v2Info.GetTextFrame("TPE1").ToString();
             title = CurrSong.ID3v2Info.GetTextFrame("TIT2").ToString();
             album = CurrSong.ID3v2Info.GetTextFrame("TALB").ToString();
             //duration = Convert.ToInt32(CurrSong.ID3v2Info.GetTextFrame("TLEN"));
             lblPath.Text = path;


             string insSql = "INSERT INTO Library(Artist,Title,Album,Path)"+
                             "VALUES('"+artist.Replace("'","''")+"','" + title.Replace("'","''") + "','"+
                             album.Replace("'","''")+ "','" +path.Replace("'","''") + "')";
             insertLib = new OleDbCommand(insSql, musLibConn);
             insertLib.ExecuteNonQuery();

             i++;
             System.GC.Collect();
         }

         pBar.Visible = false;
         lblNum.Text = Convert.ToString(filepaths.Length);
         util.setNoFiles(filepaths.Length);


Thanks for the help

Jon
AnswerRe: Syste.OutOfMemoryException [modified] Pin
Luc Pattyn11-Mar-09 14:34
sitebuilderLuc Pattyn11-Mar-09 14:34 
AnswerRe: Syste.OutOfMemoryException Pin
DaveyM6911-Mar-09 14:40
professionalDaveyM6911-Mar-09 14:40 
AnswerRe: Syste.OutOfMemoryException Pin
DaveyM6911-Mar-09 14:45
professionalDaveyM6911-Mar-09 14:45 
AnswerRe: Syste.OutOfMemoryException Pin
Member 461797111-Mar-09 14:48
Member 461797111-Mar-09 14:48 
GeneralRe: Syste.OutOfMemoryException Pin
DaveyM6911-Mar-09 14:52
professionalDaveyM6911-Mar-09 14:52 
GeneralRe: Syste.OutOfMemoryException Pin
Member 461797111-Mar-09 14:59
Member 461797111-Mar-09 14:59 
GeneralRe: Syste.OutOfMemoryException Pin
DaveyM6911-Mar-09 15:26
professionalDaveyM6911-Mar-09 15:26 
GeneralRe: Syste.OutOfMemoryException Pin
Luc Pattyn11-Mar-09 15:46
sitebuilderLuc Pattyn11-Mar-09 15:46 
GeneralRe: Syste.OutOfMemoryException Pin
DaveyM6911-Mar-09 15:56
professionalDaveyM6911-Mar-09 15:56 
GeneralRe: Syste.OutOfMemoryException Pin
Luc Pattyn11-Mar-09 16:06
sitebuilderLuc Pattyn11-Mar-09 16:06 
GeneralRe: Syste.OutOfMemoryException Pin
DaveyM6911-Mar-09 23:03
professionalDaveyM6911-Mar-09 23:03 
GeneralRe: Syste.OutOfMemoryException Pin
Member 461797111-Mar-09 15:06
Member 461797111-Mar-09 15:06 
GeneralRe: Syste.OutOfMemoryException Pin
Luc Pattyn11-Mar-09 15:13
sitebuilderLuc Pattyn11-Mar-09 15:13 
GeneralRe: Syste.OutOfMemoryException Pin
Member 461797111-Mar-09 15:16
Member 461797111-Mar-09 15:16 
GeneralRe: Syste.OutOfMemoryException [modified] Pin
Luc Pattyn11-Mar-09 15:49
sitebuilderLuc Pattyn11-Mar-09 15:49 
GeneralRe: Syste.OutOfMemoryException Pin
Member 461797111-Mar-09 16:53
Member 461797111-Mar-09 16:53 
GeneralRe: Syste.OutOfMemoryException Pin
Luc Pattyn11-Mar-09 16:10
sitebuilderLuc Pattyn11-Mar-09 16:10 

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.